[ms planner] fix changeset 6650:72f2fd93a622: we should sometime complete input map anyway
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 27 Oct 2010 08:53:14 +0200
changeset 6654 18d159a2d1ba
parent 6653 52d1568af412
child 6655 75112ff0511d
[ms planner] fix changeset 6650:72f2fd93a622: we should sometime complete input map anyway
devtools/repotest.py
server/msplanner.py
server/test/unittest_msplanner.py
--- a/devtools/repotest.py	Wed Oct 27 08:51:50 2010 +0200
+++ b/devtools/repotest.py	Wed Oct 27 08:53:14 2010 +0200
@@ -363,15 +363,15 @@
     from cubicweb.server.msplanner import PartPlanInformation
 except ImportError:
     class PartPlanInformation(object):
-        def merge_input_maps(self, *args):
+        def merge_input_maps(self, *args, **kwargs):
             pass
         def _choose_term(self, sourceterms):
             pass
 _orig_merge_input_maps = PartPlanInformation.merge_input_maps
 _orig_choose_term = PartPlanInformation._choose_term
 
-def _merge_input_maps(*args):
-    return sorted(_orig_merge_input_maps(*args))
+def _merge_input_maps(*args, **kwargs):
+    return sorted(_orig_merge_input_maps(*args, **kwargs))
 
 def _choose_term(self, sourceterms):
     # predictable order for test purpose
--- a/server/msplanner.py	Wed Oct 27 08:51:50 2010 +0200
+++ b/server/msplanner.py	Wed Oct 27 08:53:14 2010 +0200
@@ -1094,7 +1094,7 @@
             if not sourceterms:
                 del self._sourcesterms[source]
 
-    def merge_input_maps(self, allsolindices):
+    def merge_input_maps(self, allsolindices, complete=True):
         """inputmaps is a dictionary with tuple of solution indices as key with
         an associated input map as value. This function compute for each
         solution its necessary input map and return them grouped
@@ -1113,7 +1113,7 @@
         # compute a single map for each solution
         for solindices, basemap in self._inputmaps.iteritems():
             for solindex in solindices:
-                if not solindex in allsolindices:
+                if not (complete or solindex in allsolindices):
                     continue
                 solmap = mapbysol.setdefault(solindex, {})
                 solmap.update(basemap)
@@ -1294,13 +1294,15 @@
         ppi.temptable = atemptable
         vfilter = TermsFiltererVisitor(self.schema, ppi)
         steps = []
+        multifinal = len([x for x in stepdefs if x[-1]]) >= 2
         for sources, terms, solindices, scope, needsel, final in stepdefs:
             # extract an executable query using only the specified terms
             if sources[0].uri == 'system':
                 # 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)
+                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)
--- a/server/test/unittest_msplanner.py	Wed Oct 27 08:51:50 2010 +0200
+++ b/server/test/unittest_msplanner.py	Wed Oct 27 08:53:14 2010 +0200
@@ -2296,13 +2296,6 @@
     _test = test_plan
 
 
-    def test_crossed_relation_eid_1_noninvariant(self):
-        repo._type_source_cache[999999] = ('Note', 'cards', 999999)
-        self.set_debug('DBG_MS')
-        self._test('Any Y,YT WHERE X eid %(x)s, X multisource_crossed_rel Y, Y type YT',
-                   [],
-                   {'x': 999999})
-
     def test_linked_external_entities(self):
         repo._type_source_cache[999999] = ('Tag', 'system', 999999)
         self._test('Any X,XT WHERE X is Card, X title XT, T tags X, T eid %(t)s',