fix jpl/ticket/34862: msplanner bug with query generated to check if a user from ldap is owned_by himself stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 26 Jun 2009 23:37:09 +0200
branchstable
changeset 2170 6adbc965c51b
parent 2169 124fb0b9fa4b
child 2178 a73bf75a1ef9
fix jpl/ticket/34862: msplanner bug with query generated to check if a user from ldap is owned_by himself
server/msplanner.py
server/test/unittest_msplanner.py
--- a/server/msplanner.py	Fri Jun 26 11:31:57 2009 +0200
+++ b/server/msplanner.py	Fri Jun 26 23:37:09 2009 +0200
@@ -563,7 +563,9 @@
                 self._sourcesterms = {self.system_source: {}}
         elif not self.needsplit:
             if not allequals(self._sourcesterms.itervalues()):
-                for terms in self._sourcesterms.itervalues():
+                for source, terms in self._sourcesterms.iteritems():
+                    if source is self.system_source:
+                        continue
                     if any(x for x in terms if not isinstance(x, Constant)):
                         self.needsplit = True
                         return
--- a/server/test/unittest_msplanner.py	Fri Jun 26 11:31:57 2009 +0200
+++ b/server/test/unittest_msplanner.py	Fri Jun 26 23:37:09 2009 +0200
@@ -1934,6 +1934,21 @@
                      [])],
                    {'x': self.session.user.eid})
 
+    def test_nonregr14_1(self):
+        repo._type_source_cache[999999] = ('CWUser', 'ldap', 999999)
+        self._test('Any X WHERE X eid %(x)s, X owned_by U, U eid %(u)s',
+                   [('OneFetchStep', [('Any 999999 WHERE 999999 owned_by 999999', [{}])],
+                     None, None, [self.system], {}, [])],
+                   {'x': 999999, 'u': 999999})
+
+    def test_nonregr14_2(self):
+        repo._type_source_cache[999999] = ('CWUser', 'ldap', 999999)
+        repo._type_source_cache[999998] = ('Note', 'system', 999998)
+        self._test('Any X WHERE X eid %(x)s, X owned_by U, U eid %(u)s',
+                   [('OneFetchStep', [('Any 999998 WHERE 999998 owned_by 999999', [{}])],
+                     None, None, [self.system], {}, [])],
+                   {'x': 999998, 'u': 999999})
+
 
 class MSPlannerTwoSameExternalSourcesTC(BasePlannerTC):
     """test planner related feature on a 3-sources repository: