# HG changeset patch # User Sylvain Thénault # Date 1249404526 -7200 # Node ID afa99d53401c523000a2a9aaf719c80d06995e1a # Parent 3a590ff82e99e1c998c4156c38a3a4eb95c6948c [multi-source] test and fix msplanner regression diff -r 3a590ff82e99 -r afa99d53401c server/msplanner.py --- a/server/msplanner.py Fri Jul 31 14:18:53 2009 +0200 +++ b/server/msplanner.py Tue Aug 04 18:48:46 2009 +0200 @@ -100,6 +100,16 @@ AbstractSource.dont_cross_relations = () AbstractSource.cross_relations = () +def need_source_access_relation(vargraph): + if not vargraph: + return False + # check vargraph contains some other relation than the identity relation + # test of key nature since it may be a variable name (don't care about that) + # or a 2-uple (var1, var2) associated to the relation to traverse to go from + # var1 to var2 + return any(key for key, val in vargraph.iteritems() + if isinstance(key, tuple) and val != 'identity') + def need_aggr_step(select, sources, stepdefs=None): """return True if a temporary table is necessary to store some partial results to execute the given query @@ -559,7 +569,8 @@ # 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: + not self.rqlst.defined_vars and \ + not need_source_access_relation(self.rqlst.vargraph): self._sourcesterms = {self.system_source: {}} elif not self.needsplit: if not allequals(self._sourcesterms.itervalues()): diff -r 3a590ff82e99 -r afa99d53401c server/test/unittest_msplanner.py --- a/server/test/unittest_msplanner.py Fri Jul 31 14:18:53 2009 +0200 +++ b/server/test/unittest_msplanner.py Tue Aug 04 18:48:46 2009 +0200 @@ -1957,6 +1957,12 @@ None, None, [self.system], {}, [])], {'x': 999998, 'u': 999999}) + def test_nonregr_identity_no_source_access(self): + repo._type_source_cache[999999] = ('CWUser', 'ldap', 999998) + self._test('Any S WHERE S identity U, S eid %(s)s, U eid %(u)s', + [('OneFetchStep', [('Any 999999 WHERE 999999 identity 999999', [{}])], + None, None, [self.system], {}, [])], + {'s': 999999, 'u': 999999}) class MSPlannerTwoSameExternalSourcesTC(BasePlannerTC): """test planner related feature on a 3-sources repository: