# HG changeset patch # User Sylvain Thénault # Date 1294138751 -3600 # Node ID 5d016d5bacca203db0971942dcb7a10ecc0e48b0 # Parent 28b11ecf319b0326a3dfc4710144a439df15f1d3 [ms] fix ms planner crash on some ambiguous queries, as demonstrated in a comment on http://www.cubicweb.org/ticket/1382452 diff -r 28b11ecf319b -r 5d016d5bacca server/msplanner.py --- a/server/msplanner.py Tue Jan 04 09:07:22 2011 +0100 +++ b/server/msplanner.py Tue Jan 04 11:59:11 2011 +0100 @@ -1329,8 +1329,8 @@ # in this case we have to merge input maps before call to # filter so already processed restriction are correctly # removed - solsinputmaps = ppi.merge_input_maps(solindices, - complete=not (final and multifinal)) + solsinputmaps = ppi.merge_input_maps( + solindices, complete=not (final and multifinal)) for solindices, inputmap in solsinputmaps: minrqlst, insertedvars = vfilter.filter( sources, terms, scope, set(solindices), needsel, final) @@ -1347,7 +1347,8 @@ minrqlst, insertedvars = vfilter.filter( sources, terms, scope, solindices, needsel, final) if final: - solsinputmaps = ppi.merge_input_maps(solindices) + solsinputmaps = ppi.merge_input_maps( + solindices, complete=not (final and multifinal)) if len(solsinputmaps) > 1: refrqlst = minrqlst for solindices, inputmap in solsinputmaps: diff -r 28b11ecf319b -r 5d016d5bacca server/test/unittest_msplanner.py --- a/server/test/unittest_msplanner.py Tue Jan 04 09:07:22 2011 +0100 +++ b/server/test/unittest_msplanner.py Tue Jan 04 11:59:11 2011 +0100 @@ -18,6 +18,7 @@ from logilab.common.decorators import clear_cache +from yams.buildobjs import RelationDefinition from rql import BadRQLQuery from cubicweb.devtools import init_test_database @@ -1651,6 +1652,40 @@ {'A': 'table0.C0', 'B': 'table1.C0', 'DEP': 'table2.C0', 'P': 'table2.C1'}, [])]) + def test_crossed_relation_noeid_invariant(self): + # see comment in http://www.cubicweb.org/ticket/1382452 + self.schema.add_relation_def( + RelationDefinition(subject='Note', name='multisource_crossed_rel', object='Affaire')) + self.repo.set_schema(self.schema) + try: + self._test('DISTINCT Any P,DEP WHERE P type "cubicweb-foo", P multisource_crossed_rel DEP', + [('FetchStep', + [('Any DEP WHERE DEP is Note', [{'DEP': 'Note'}])], + [self.cards, self.system], None, {'DEP': 'table0.C0'}, []), + ('FetchStep', + [(u'Any P WHERE P type "cubicweb-foo", P is Note', [{'P': 'Note'}])], + [self.cards, self.system], None, {'P': 'table1.C0'}, []), + ('UnionStep', None, None, + [('OneFetchStep', + [('DISTINCT Any P,DEP WHERE P multisource_crossed_rel DEP, DEP is Note, P is Note', + [{'DEP': 'Note', 'P': 'Note'}])], + None, None, [self.cards], None, []), + ('OneFetchStep', + [('DISTINCT Any P,DEP WHERE P multisource_crossed_rel DEP, DEP is Note, P is Note', + [{'DEP': 'Note', 'P': 'Note'}])], + None, None, [self.system], + {'DEP': 'table0.C0', 'P': 'table1.C0'}, + []), + ('OneFetchStep', + [('DISTINCT Any P,DEP WHERE P multisource_crossed_rel DEP, DEP is Affaire, P is Note', + [{'DEP': 'Affaire', 'P': 'Note'}])], + None, None, [self.system], {'P': 'table1.C0'}, + [])]) + ]) + finally: + self.schema.del_relation_def('Note', 'multisource_crossed_rel', 'Affaire') + self.repo.set_schema(self.schema) + # edition queries tests ################################################### def test_insert_simplified_var_1(self):