#344177: ms planning bug with "Any X WHERE X eid 123" and 123 coming from an external source stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 25 Jun 2009 11:26:46 +0200
branchstable
changeset 2165 dd40c375044e
parent 2164 e3aeb6e6c3bb
child 2168 f1d5d01dd345
#344177: ms planning bug with "Any X WHERE X eid 123" and 123 coming from an external source
server/msplanner.py
server/test/unittest_msplanner.py
--- a/server/msplanner.py	Thu Jun 25 08:26:25 2009 +0200
+++ b/server/msplanner.py	Thu Jun 25 11:26:46 2009 +0200
@@ -553,6 +553,14 @@
         # NOTE: < 2 since may be 0 on queries such as Any X WHERE X eid 2
         if len(self._sourcesterms) < 2:
             self.needsplit = False
+            # if this is not the system source but we have only constant terms
+            # and no relation (other than eid), apply query on the system source
+            #
+            # testing for rqlst with nothing in vargraph nor defined_vars is the
+            # simplest way the check the condition explained below
+            if not self.system_source in self._sourcesterms and \
+                   not self.rqlst.vargraph and not self.rqlst.defined_vars:
+                self._sourcesterms = {self.system_source: {}}
         elif not self.needsplit:
             if not allequals(self._sourcesterms.itervalues()):
                 for terms in self._sourcesterms.itervalues():
--- a/server/test/unittest_msplanner.py	Thu Jun 25 08:26:25 2009 +0200
+++ b/server/test/unittest_msplanner.py	Thu Jun 25 11:26:46 2009 +0200
@@ -2072,6 +2072,14 @@
                      )],
                    {'x': 999999})
 
+    def test_nonregr_eid_query(self):
+        self.repo._type_source_cache[999999] = ('Note', 'cards', 999999)
+        self._test('Any X WHERE X eid 999999',
+                   [('OneFetchStep', [('Any 999999', [{}])],
+                     None, None, [self.system], {}, []
+                     )],
+                   {'x': 999999})
+
 
 
 class FakeVCSSource(AbstractSource):