one more ms planning bug stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 17 Jun 2009 20:46:37 +0200
branchstable
changeset 2114 862f27d94af4
parent 2113 58489d113215
child 2115 c48ff1d0acc4
one more ms planning bug
server/msplanner.py
server/test/unittest_msplanner.py
--- a/server/msplanner.py	Tue Jun 16 14:15:18 2009 +0200
+++ b/server/msplanner.py	Wed Jun 17 20:46:37 2009 +0200
@@ -361,7 +361,7 @@
                         self._set_source_for_term(source, const)
                         # if system source is used, add every rewritten constant
                         # to its supported terms even when associated entity
-                        # doesn't actually comes from it so we get a changes
+                        # doesn't actually come from it so we get a changes
                         # that allequals will return True as expected when
                         # computing needsplit
                         # check const is used in a relation restriction
@@ -555,7 +555,12 @@
             self.needsplit = False
         elif not self.needsplit:
             if not allequals(self._sourcesterms.itervalues()):
-                self.needsplit = True
+                for terms in self._sourcesterms.itervalues():
+                    if any(x for x in terms if not isinstance(x, Constant)):
+                        self.needsplit = True
+                        return
+                self._sourcesterms = {self.system_source: {}}
+                self.needsplit = False
             else:
                 sample = self._sourcesterms.itervalues().next()
                 if len(sample) > 1:
--- a/server/test/unittest_msplanner.py	Tue Jun 16 14:15:18 2009 +0200
+++ b/server/test/unittest_msplanner.py	Wed Jun 17 20:46:37 2009 +0200
@@ -2118,6 +2118,15 @@
                      None, None, [self.vcs], {}, [])
                     ])
 
+    def test_nonregr_fully_simplified_extsource(self):
+        self.repo._type_source_cache[999998] = ('Note', 'vcs', 999998)
+        self.repo._type_source_cache[999999] = ('Note', 'vcs', 999999)
+        self.repo._type_source_cache[1000000] = ('Note', 'system', 1000000)
+        self._test('DISTINCT Any T,FALSE,L,M WHERE L eid 1000000, M eid 999999, T eid 999998',
+                   [('OneFetchStep', [('DISTINCT Any 999998,FALSE,1000000,999999', [{}])],
+                     None, None, [self.system], {}, [])
+                    ])
+
 
 if __name__ == '__main__':
     from logilab.common.testlib import unittest_main