[rql rewrite] backout 7177:f2a976cf7dac : since EXISTS is the variable scope, we want to insert snippets here anyway (other solution would be to NOT insert snippets at all in such case). Closes #1625464
--- a/rqlrewrite.py Fri Apr 22 16:23:34 2011 +0200
+++ b/rqlrewrite.py Tue Apr 26 16:14:43 2011 +0200
@@ -257,11 +257,6 @@
insert_scope = None
for vi in self.varinfos:
scope = vi.get('stinfo', {}).get('scope', self.select)
- while True:
- negstmt = scope.neged()
- if negstmt is None:
- break
- scope = negstmt.scope
if insert_scope is None:
insert_scope = scope
else:
--- a/test/unittest_rqlrewrite.py Fri Apr 22 16:23:34 2011 +0200
+++ b/test/unittest_rqlrewrite.py Tue Apr 26 16:14:43 2011 +0200
@@ -353,14 +353,21 @@
self.failUnlessEqual(rqlst.as_string(),
u"Any C WHERE C is Card, EXISTS(C owned_by A, A is CWUser)")
- def test_rqlexpr_not_relation1(self):
+ def test_rqlexpr_not_relation_1_1(self):
constraint = RRQLExpression('X owned_by Z, Z login "hop"', 'X')
rqlst = parse('Affaire A WHERE NOT EXISTS(A documented_by C)')
rewrite(rqlst, {('C', 'X'): (constraint,)}, {}, 'X')
self.failUnlessEqual(rqlst.as_string(),
u'Any A WHERE NOT EXISTS(A documented_by C, EXISTS(C owned_by B, B login "hop", B is CWUser), C is Card), A is Affaire')
- def test_rqlexpr_not_relation2(self):
+ def test_rqlexpr_not_relation_1_2(self):
+ constraint = RRQLExpression('X owned_by Z, Z login "hop"', 'X')
+ rqlst = parse('Affaire A WHERE NOT EXISTS(A documented_by C)')
+ rewrite(rqlst, {('A', 'X'): (constraint,)}, {}, 'X')
+ self.failUnlessEqual(rqlst.as_string(),
+ u'Any A WHERE NOT EXISTS(A documented_by C, C is Card), A is Affaire, EXISTS(A owned_by B, B login "hop", B is CWUser)')
+
+ def test_rqlexpr_not_relation_2(self):
constraint = RRQLExpression('X owned_by Z, Z login "hop"', 'X')
rqlst = rqlhelper.parse('Affaire A WHERE NOT A documented_by C', annotate=False)
rewrite(rqlst, {('C', 'X'): (constraint,)}, {}, 'X')