[rql annotation] add test and fix for bug introduced by 5004:4cc020ee70e2. While it sounded good, it wasn't because stinfo['relations'] didn't include anymore stinfo['typerels']
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 07 Apr 2010 09:24:00 +0200
changeset 5173 73760bbb66bd
parent 5163 3079b8345915
child 5174 78438ad513ca
[rql annotation] add test and fix for bug introduced by 5004:4cc020ee70e2. While it sounded good, it wasn't because stinfo['relations'] didn't include anymore stinfo['typerels']
server/rqlannotation.py
server/test/unittest_rqlannotation.py
--- a/server/rqlannotation.py	Wed Apr 07 09:45:15 2010 +0200
+++ b/server/rqlannotation.py	Wed Apr 07 09:24:00 2010 +0200
@@ -339,11 +339,7 @@
     def set_rel_constraint(self, term, rel, etypes_func):
         if isinstance(term, VariableRef) and self.is_ambiguous(term.variable):
             var = term.variable
-            if var.stinfo['typerel'] is not None:
-                sub = 1
-            else:
-                sub = 0
-            if len(var.stinfo['relations']) - sub == 1 \
+            if len(var.stinfo['relations']) == 1 \
                    or rel.sqlscope is var.sqlscope or rel.r_type == 'identity':
                 self.restrict(var, frozenset(etypes_func()))
                 try:
--- a/server/test/unittest_rqlannotation.py	Wed Apr 07 09:45:15 2010 +0200
+++ b/server/test/unittest_rqlannotation.py	Wed Apr 07 09:24:00 2010 +0200
@@ -100,6 +100,12 @@
         self.assertEquals(rqlst.defined_vars['X']._q_invariant, False)
         self.assertEquals(rqlst.defined_vars['Y']._q_invariant, False)
 
+    def test_8(self):
+        # DISTINCT Any P WHERE P require_group %(g)s, NOT %(u)s has_group_permission P, P is CWPermission
+        rqlst = self._prepare('DISTINCT Any X WHERE A concerne X, NOT N migrated_from X, '
+                              'X is Note, N eid 1')
+        self.assertEquals(rqlst.defined_vars['X']._q_invariant, False)
+
     def test_diff_scope_identity_deamb(self):
         rqlst = self._prepare('Any X WHERE X concerne Y, Y is Note, EXISTS(Y identity Z, Z migrated_from N)')
         self.assertEquals(rqlst.defined_vars['Z']._q_invariant, True)