fix rqlannotation bug w/ identity relation in subscope 3.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 16 Sep 2009 16:36:08 +0200
branch3.5
changeset 3249 280080eadb22
parent 3248 db09803df8b2
child 3250 65618fd34548
fix rqlannotation bug w/ identity relation in subscope
server/rqlannotation.py
server/test/unittest_rqlannotation.py
--- a/server/rqlannotation.py	Wed Sep 16 16:35:24 2009 +0200
+++ b/server/rqlannotation.py	Wed Sep 16 16:36:08 2009 +0200
@@ -331,7 +331,7 @@
         if isinstance(term, VariableRef) and self.is_ambiguous(term.variable):
             var = term.variable
             if len(var.stinfo['relations'] - var.stinfo['typerels']) == 1 \
-                   or rel.sqlscope is var.sqlscope:
+                   or rel.sqlscope is var.sqlscope or rel.r_type == 'identity':
                 self.restrict(var, frozenset(etypes_func()))
                 try:
                     self.maydeambrels[var].add(rel)
--- a/server/test/unittest_rqlannotation.py	Wed Sep 16 16:35:24 2009 +0200
+++ b/server/test/unittest_rqlannotation.py	Wed Sep 16 16:36:08 2009 +0200
@@ -95,6 +95,11 @@
         self.assertEquals(rqlst.defined_vars['X']._q_invariant, False)
         self.assertEquals(rqlst.defined_vars['Y']._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)
+        self.assertEquals(rqlst.defined_vars['Y']._q_invariant, True)
+
     def test_optional_inlined(self):
         rqlst = self._prepare('Any X,S where X from_state S?')
         self.assertEquals(rqlst.defined_vars['X']._q_invariant, False)