[ms] fix ms planner crash on some ambiguous queries, as demonstrated in a comment on http://www.cubicweb.org/ticket/1382452 stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 04 Jan 2011 11:59:11 +0100
branchstable
changeset 6759 5d016d5bacca
parent 6758 28b11ecf319b
child 6760 2c1fc68ac258
child 6761 84b67ae41a0d
[ms] fix ms planner crash on some ambiguous queries, as demonstrated in a comment on http://www.cubicweb.org/ticket/1382452
server/msplanner.py
server/test/unittest_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:
--- 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):