# HG changeset patch # User Sylvain Thénault # Date 1280830621 -7200 # Node ID 37a37e5ba33050c1b110c8ea4bd575de7f7ac670 # Parent 1ab6978b72b8eeab4175c5fcc4c24234f49e7129 [ms] fix a ms plannification bug with NOT is diff -r 1ab6978b72b8 -r 37a37e5ba330 server/msplanner.py --- a/server/msplanner.py Mon Aug 02 15:36:44 2010 +0200 +++ b/server/msplanner.py Tue Aug 03 12:17:01 2010 +0200 @@ -1441,13 +1441,14 @@ return None, node if not self._relation_supported(node): raise UnsupportedBranch() - # don't copy type restriction unless this is the only relation for the - # rhs variable, else they'll be reinserted later as needed (else we may - # copy a type restriction while the variable is not actually used) - elif not any(self._relation_supported(rel) - for rel in node.children[0].variable.stinfo['relations']): - rel, node = self.visit_default(node, newroot, terms) - return rel, node + # don't copy type restriction unless this is the only supported relation + # for the lhs variable, else they'll be reinserted later as needed (in + # other cases we may copy a type restriction while the variable is not + # actually used) + elif not (node.neged(strict=True) or + any(self._relation_supported(rel) + for rel in node.children[0].variable.stinfo['relations'])): + return self.visit_default(node, newroot, terms) else: raise UnsupportedBranch() rschema = self.schema.rschema(node.r_type) diff -r 1ab6978b72b8 -r 37a37e5ba330 server/test/unittest_msplanner.py --- a/server/test/unittest_msplanner.py Mon Aug 02 15:36:44 2010 +0200 +++ b/server/test/unittest_msplanner.py Tue Aug 03 12:17:01 2010 +0200 @@ -2196,6 +2196,60 @@ {'x': 999999}) + def test_nonregr_not_is(self): + self._test("Any X WHERE X owned_by U, U login 'anon', NOT X is Comment", + [('FetchStep', [('Any X WHERE X is IN(Card, Note, State)', + [{'X': 'Note'}, {'X': 'State'}, {'X': 'Card'}])], + [self.cards, self.cards2, self.system], + None, {'X': 'table0.C0'}, []), + ('UnionStep', None, None, + [('OneFetchStep', + [(u'Any X WHERE X owned_by U, U login "anon", U is CWUser, X is IN(Affaire, BaseTransition, Basket, Bookmark, CWAttribute, CWCache, CWConstraint, CWConstraintType, CWEType, CWGroup, CWPermission, CWProperty, CWRType, CWRelation, CWUser, Division, Email, EmailAddress, EmailPart, EmailThread, ExternalUri, File, Folder, Personne, RQLExpression, Societe, SubDivision, SubWorkflowExitPoint, Tag, TrInfo, Transition, Workflow, WorkflowTransition)', + [{'U': 'CWUser', 'X': 'Affaire'}, + {'U': 'CWUser', 'X': 'BaseTransition'}, + {'U': 'CWUser', 'X': 'Basket'}, + {'U': 'CWUser', 'X': 'Bookmark'}, + {'U': 'CWUser', 'X': 'CWAttribute'}, + {'U': 'CWUser', 'X': 'CWCache'}, + {'U': 'CWUser', 'X': 'CWConstraint'}, + {'U': 'CWUser', 'X': 'CWConstraintType'}, + {'U': 'CWUser', 'X': 'CWEType'}, + {'U': 'CWUser', 'X': 'CWGroup'}, + {'U': 'CWUser', 'X': 'CWPermission'}, + {'U': 'CWUser', 'X': 'CWProperty'}, + {'U': 'CWUser', 'X': 'CWRType'}, + {'U': 'CWUser', 'X': 'CWRelation'}, + {'U': 'CWUser', 'X': 'CWUser'}, + {'U': 'CWUser', 'X': 'Division'}, + {'U': 'CWUser', 'X': 'Email'}, + {'U': 'CWUser', 'X': 'EmailAddress'}, + {'U': 'CWUser', 'X': 'EmailPart'}, + {'U': 'CWUser', 'X': 'EmailThread'}, + {'U': 'CWUser', 'X': 'ExternalUri'}, + {'U': 'CWUser', 'X': 'File'}, + {'U': 'CWUser', 'X': 'Folder'}, + {'U': 'CWUser', 'X': 'Personne'}, + {'U': 'CWUser', 'X': 'RQLExpression'}, + {'U': 'CWUser', 'X': 'Societe'}, + {'U': 'CWUser', 'X': 'SubDivision'}, + {'U': 'CWUser', 'X': 'SubWorkflowExitPoint'}, + {'U': 'CWUser', 'X': 'Tag'}, + {'U': 'CWUser', 'X': 'TrInfo'}, + {'U': 'CWUser', 'X': 'Transition'}, + {'U': 'CWUser', 'X': 'Workflow'}, + {'U': 'CWUser', 'X': 'WorkflowTransition'}])], + None, None, + [self.system], {}, []), + ('OneFetchStep', + [(u'Any X WHERE X owned_by U, U login "anon", U is CWUser, X is IN(Card, Note, State)', + [{'U': 'CWUser', 'X': 'Note'}, + {'U': 'CWUser', 'X': 'State'}, + {'U': 'CWUser', 'X': 'Card'}])], + None, None, + [self.system], {'X': 'table0.C0'}, []) + ]) + ]) + class FakeVCSSource(AbstractSource): uri = 'ccc'