[schema / rql] fix mainvars of RRQLExpression with parens stable
authorFlorent Cayré <florent.cayre@gmail.com>
Fri, 01 Jul 2011 15:26:12 +0200
branchstable
changeset 7603 1302aa6ba4da
parent 7602 fbda46a4944f
child 7604 1eb6090311ff
child 7611 01296dd111d5
[schema / rql] fix mainvars of RRQLExpression with parens
schema.py
test/unittest_schema.py
--- a/schema.py	Fri Jul 01 15:23:25 2011 +0200
+++ b/schema.py	Fri Jul 01 15:26:12 2011 +0200
@@ -645,9 +645,10 @@
 
 def split_expression(rqlstring):
     for expr in rqlstring.split(','):
-        for noparen in expr.split('('):
-            for word in noparen.split():
-                yield word
+        for noparen1 in expr.split('('):
+            for noparen2 in noparen1.split(')'):
+                for word in noparen2.split():
+                    yield word
 
 def normalize_expression(rqlstring):
     """normalize an rql expression to ease schema synchronization (avoid
--- a/test/unittest_schema.py	Fri Jul 01 15:23:25 2011 +0200
+++ b/test/unittest_schema.py	Fri Jul 01 15:26:12 2011 +0200
@@ -315,8 +315,8 @@
 
 class GuessRrqlExprMainVarsTC(TestCase):
     def test_exists(self):
-        mainvars = guess_rrqlexpr_mainvars(normalize_expression('NOT EXISTS(O team_competition C, C level < 3)'))
-        self.assertEqual(mainvars, set(['O']))
+        mainvars = guess_rrqlexpr_mainvars(normalize_expression('NOT EXISTS(O team_competition C, C level < 3, C concerns S)'))
+        self.assertEqual(mainvars, set(['S', 'O']))
 
 
 if __name__ == '__main__':