# HG changeset patch # User Sylvain Thénault # Date 1288945063 -3600 # Node ID 5eb2f1f2c277f98b97e0741fe848f12544b5c9ff # Parent 2008fd2f628ccef13ac681f320be64ea64f18a97 [ms planning] test and fix bad plannification of a query used on cascading delete of a deleted (external) entity relations diff -r 2008fd2f628c -r 5eb2f1f2c277 server/msplanner.py --- a/server/msplanner.py Fri Nov 05 09:14:10 2010 +0100 +++ b/server/msplanner.py Fri Nov 05 09:17:43 2010 +0100 @@ -745,6 +745,15 @@ and self._need_ext_source_access(term, rel): self.needsplit = True return + else: + # remove sources only accessing to constant nodes + for source, terms in self._sourcesterms.items(): + if source is self.system_source: + continue + if not any(x for x in terms if not isinstance(x, Constant)): + del self._sourcesterms[source] + if len(self._sourcesterms) < 2: + self.needsplit = False @cached def _need_ext_source_access(self, var, rel): diff -r 2008fd2f628c -r 5eb2f1f2c277 server/test/unittest_msplanner.py --- a/server/test/unittest_msplanner.py Fri Nov 05 09:14:10 2010 +0100 +++ b/server/test/unittest_msplanner.py Fri Nov 05 09:17:43 2010 +0100 @@ -1709,6 +1709,18 @@ ], {'x': ueid, 'y': ueid}) + def test_delete_relation3(self): + repo._type_source_cache[999999] = ('Note', 'cards', 999999) + self._test('DELETE Y multisource_inlined_rel X WHERE X eid %(x)s, NOT (Y cw_source S, S name %(source)s)', + [('DeleteRelationsStep', + [('OneFetchStep', + [('Any Y,999999 WHERE Y multisource_inlined_rel 999999, NOT EXISTS(Y cw_source S, S name "cards"), S is CWSource, Y is IN(Card, Note)', + [{'S': 'CWSource', 'Y': 'Card'}, {'S': 'CWSource', 'Y': 'Note'}])], + None, None, [self.system], {}, + [])] + )], + {'x': 999999, 'source': 'cards'}) + def test_delete_entity1(self): repo._type_source_cache[999999] = ('Note', 'system', 999999) self._test('DELETE Note X WHERE X eid %(x)s, NOT Y multisource_rel X',