# HG changeset patch # User Sylvain Thénault # Date 1245922006 -7200 # Node ID dd40c375044e70627c0be93931dc8bdfcf18f66d # Parent e3aeb6e6c3bb5c18e8dcf61bae9d654beda6c036 #344177: ms planning bug with "Any X WHERE X eid 123" and 123 coming from an external source diff -r e3aeb6e6c3bb -r dd40c375044e server/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(): diff -r e3aeb6e6c3bb -r dd40c375044e server/test/unittest_msplanner.py --- 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):