--- a/stcheck.py Wed May 18 15:28:34 2011 +0200
+++ b/stcheck.py Thu May 19 09:39:37 2011 +0200
@@ -1,4 +1,4 @@
-# copyright 2004-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2004-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of rql.
@@ -665,6 +665,9 @@
update_attrvars(var, relation, lhs)
def update_attrvars(var, relation, lhs):
+ if var.stinfo['relations'] - var.stinfo['rhsrelations']:
+ raise BadRQLQuery('variable %s should not be used as rhs of attribute relation %s'
+ % (var.name, relation))
# stinfo['attrvars'] is set of couple (lhs variable name, relation name)
# where the `var` attribute variable is used
lhsvar = getattr(lhs, 'variable', None)
--- a/test/unittest_stcheck.py Wed May 18 15:28:34 2011 +0200
+++ b/test/unittest_stcheck.py Thu May 19 09:39:37 2011 +0200
@@ -1,4 +1,4 @@
-# copyright 2004-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2004-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of rql.
@@ -313,5 +313,10 @@
self.failUnless(C.scope is rqlst.with_[0].query.children[0], C.scope)
self.assertEqual(len(C.stinfo['relations']), 2)
+ def test_no_attr_var_if_uid_rel(self):
+ with self.assertRaises(BadRQLQuery) as cm:
+ self.parse('Any X, Y WHERE X work_for Z, Y work_for Z, X eid > Y')
+ self.assertEqual(str(cm.exception), 'variable Y should not be used as rhs of attribute relation X eid > Y')
+
if __name__ == '__main__':
unittest_main()