fix mainvars detection bug with EXISTS (paren, actually) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 18 Dec 2009 10:26:47 +0100
branchstable
changeset 4132 440d383367eb
parent 4131 d8ca873142f4
child 4133 24ffe983abfc
fix mainvars detection bug with EXISTS (paren, actually)
schema.py
test/unittest_schema.py
--- a/schema.py	Thu Dec 17 17:22:36 2009 +0100
+++ b/schema.py	Fri Dec 18 10:26:47 2009 +0100
@@ -137,8 +137,9 @@
 
 def split_expression(rqlstring):
     for expr in rqlstring.split(','):
-        for word in expr.split():
-            yield word
+        for noparen in expr.split('('):
+            for word in noparen.split():
+                yield word
 
 def normalize_expression(rqlstring):
     """normalize an rql expression to ease schema synchronization (avoid
--- a/test/unittest_schema.py	Thu Dec 17 17:22:36 2009 +0100
+++ b/test/unittest_schema.py	Fri Dec 18 10:26:47 2009 +0100
@@ -22,7 +22,7 @@
     CubicWebSchema, CubicWebEntitySchema, CubicWebSchemaLoader,
     RQLConstraint, RQLUniqueConstraint, RQLVocabularyConstraint,
     ERQLExpression, RRQLExpression,
-    normalize_expression, order_eschemas)
+    normalize_expression, order_eschemas, guess_rrqlexpr_mainvars)
 from cubicweb.devtools import TestServerConfiguration as TestConfiguration
 
 DATADIR = join(dirname(__file__), 'data')
@@ -275,5 +275,10 @@
         self.assertEquals(normalize_expression('X  bla Y,Y blur Z  ,  Z zigoulou   X '),
                                                'X bla Y, Y blur Z, Z zigoulou X')
 
+class GuessRrqlExprMainVarsTC(TestCase):
+    def test_exists(self):
+        mainvars = guess_rrqlexpr_mainvars(normalize_expression('NOT EXISTS(O team_competition C, C level < 3)'))
+        self.assertEquals(mainvars, 'O')
+
 if __name__ == '__main__':
     unittest_main()