# HG changeset patch # User Sylvain Thénault # Date 1245922084 -7200 # Node ID f1d5d01dd345bbbdca7e3a75aa4620b0027fbfae # Parent 6cc1c9288ad1ac019cc0d6d3eb6ec0515d24bb25# Parent dd40c375044e70627c0be93931dc8bdfcf18f66d merge diff -r 6cc1c9288ad1 -r f1d5d01dd345 server/msplanner.py --- a/server/msplanner.py Thu Jun 25 11:27:39 2009 +0200 +++ b/server/msplanner.py Thu Jun 25 11:28:04 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 6cc1c9288ad1 -r f1d5d01dd345 server/test/unittest_msplanner.py --- a/server/test/unittest_msplanner.py Thu Jun 25 11:27:39 2009 +0200 +++ b/server/test/unittest_msplanner.py Thu Jun 25 11:28:04 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):