[rql2sql] fix bug with NOT in "fake" having terms stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 01 Feb 2011 10:08:44 +0100
branchstable
changeset 6929 e9464d975908
parent 6928 62b8ef1e859a
child 6930 118881289a31
[rql2sql] fix bug with NOT in "fake" having terms
server/sources/rql2sql.py
server/test/unittest_rql2sql.py
--- a/server/sources/rql2sql.py	Tue Feb 01 10:29:56 2011 +0100
+++ b/server/sources/rql2sql.py	Tue Feb 01 10:08:44 2011 +0100
@@ -416,7 +416,7 @@
                     p = compnode.parent
                     oor = None
                     while not isinstance(p, Select):
-                        if isinstance(p, Or):
+                        if isinstance(p, (Or, Not)):
                             oor = p
                         p = p.parent
                     if oor is not None:
@@ -434,7 +434,7 @@
             while not isinstance(p, Select):
                 if p in ors or p is None: # p is None for nodes already in fakehaving
                     break
-                if isinstance(p, Or):
+                if isinstance(p, (Or, Not)):
                     oor = p
                 p = p.parent
             else:
--- a/server/test/unittest_rql2sql.py	Tue Feb 01 10:29:56 2011 +0100
+++ b/server/test/unittest_rql2sql.py	Tue Feb 01 10:08:44 2011 +0100
@@ -183,7 +183,7 @@
 ]
 
 
-ADVANCED= [
+ADVANCED = [
     ("Societe S WHERE S nom 'Logilab' OR S nom 'Caesium'",
      '''SELECT _S.cw_eid
 FROM cw_Societe AS _S
@@ -572,6 +572,11 @@
     ('Any 1 WHERE X in_group G, X is CWUser',
      '''SELECT 1
 FROM in_group_relation AS rel_in_group0'''),
+
+    ('CWEType X WHERE X name CV, X description V HAVING NOT V=CV AND NOT V = "parent"',
+     '''SELECT _X.cw_eid
+FROM cw_CWEType AS _X
+WHERE NOT (EXISTS(SELECT 1 WHERE _X.cw_description=parent)) AND NOT (EXISTS(SELECT 1 WHERE _X.cw_description=_X.cw_name))'''),
     ]