[multi-sources] closes #1918120: drop behaviour leading to wrong result as demonstrated by the ticket stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 08 Sep 2011 16:35:45 +0200
branchstable
changeset 7771 59ddc2dbe7e0
parent 7770 a17145243e04
child 7772 e4f7e9b9f436
[multi-sources] closes #1918120: drop behaviour leading to wrong result as demonstrated by the ticket The formerly implemented behaviour doesn't seems to be useful, nor to have a chance to be correct. At least no test case demonstrate the opposite, so I've dropped it.
server/msplanner.py
server/test/unittest_msplanner.py
server/test/unittest_multisources.py
--- a/server/msplanner.py	Thu Sep 08 10:54:25 2011 +0200
+++ b/server/msplanner.py	Thu Sep 08 16:35:45 2011 +0200
@@ -1623,17 +1623,7 @@
     def visit_relation(self, node, newroot, terms):
         if not node.is_types_restriction():
             if not node in terms and node in self.skip and self.solindices.issubset(self.skip[node]):
-                if not self.schema.rschema(node.r_type).final:
-                    # can't really skip the relation if one variable is selected
-                    # and only referenced by this relation
-                    for vref in node.iget_nodes(VariableRef):
-                        stinfo = vref.variable.stinfo
-                        if stinfo['selected'] and len(stinfo['relations']) == 1:
-                            break
-                    else:
-                        return None, node
-                else:
-                    return None, node
+                return None, node
             if not self._relation_supported(node):
                 raise UnsupportedBranch()
         # don't copy type restriction unless this is the only supported relation
--- a/server/test/unittest_msplanner.py	Thu Sep 08 10:54:25 2011 +0200
+++ b/server/test/unittest_msplanner.py	Thu Sep 08 16:35:45 2011 +0200
@@ -1212,12 +1212,12 @@
                                     [{'X': 'Note', 'S': 'State'}])],
                      [self.cards, self.system], None, {'X': 'table0.C0', 'S': 'table0.C1'}, []),
                      ('UnionStep', None, None,
-                      [('OneFetchStep', [('Any X,S,U WHERE X in_state S, X todo_by U, S is State, U is CWUser, X is Note',
+                      [('OneFetchStep', [('Any X,S,U WHERE X in_state S, X todo_by U, S is State, U is Personne, X is Affaire',
+                                          [{'X': 'Affaire', 'S': 'State', 'U': 'Personne'}])],
+                        None, None, [self.system], {}, []),
+                       ('OneFetchStep', [('Any X,S,U WHERE X todo_by U, S is State, U is CWUser, X is Note',
                                           [{'X': 'Note', 'S': 'State', 'U': 'CWUser'}])],
                         None, None, [self.system], {'X': 'table0.C0', 'S': 'table0.C1'}, []),
-                       ('OneFetchStep', [('Any X,S,U WHERE X in_state S, X todo_by U, S is State, U is Personne, X is Affaire',
-                                          [{'X': 'Affaire', 'S': 'State', 'U': 'Personne'}])],
-                        None, None, [self.system], {}, []),
                        ])
                     ])
 
@@ -2456,6 +2456,21 @@
                      [])],
                    {'x': 999999})
 
+    def test_nonregr_dont_readd_already_processed_relation(self):
+        self._test('Any WO,D,SO WHERE WO is Note, D tags WO, WO in_state SO',
+                   [('FetchStep',
+                     [('Any WO,SO WHERE WO in_state SO, SO is State, WO is Note',
+                       [{'SO': 'State', 'WO': 'Note'}])],
+                     [self.cards, self.system], None,
+                     {'SO': 'table0.C1', 'WO': 'table0.C0'},
+                     []),
+                    ('OneFetchStep',
+                     [('Any WO,D,SO WHERE D tags WO, D is Tag, SO is State, WO is Note',
+                       [{'D': 'Tag', 'SO': 'State', 'WO': 'Note'}])],
+                     None, None, [self.system],
+                     {'SO': 'table0.C1', 'WO': 'table0.C0'},
+                     [])
+                    ])
 
 class MSPlannerTwoSameExternalSourcesTC(BasePlannerTC):
     """test planner related feature on a 3-sources repository:
--- a/server/test/unittest_multisources.py	Thu Sep 08 10:54:25 2011 +0200
+++ b/server/test/unittest_multisources.py	Thu Sep 08 16:35:45 2011 +0200
@@ -381,6 +381,9 @@
     def test_nonregr3(self):
         self.sexecute('DELETE Card X WHERE X eid %(x)s, NOT X multisource_inlined_rel Y', {'x': self.ic1})
 
+    def test_nonregr4(self):
+        self.sexecute('Any X,S,U WHERE X in_state S, X todo_by U')
+
     def test_delete_source(self):
         req = self.request()
         req.execute('DELETE CWSource S WHERE S name "extern"')