fix simplification bug with ored uid relations stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 09 Jun 2010 12:00:44 +0200
branchstable
changeset 550 bf5d7daf7cc9
parent 549 5d50dfb146a1
child 551 db05b88729b2
fix simplification bug with ored uid relations
ChangeLog
stcheck.py
test/unittest_stcheck.py
--- a/ChangeLog	Mon Jun 07 13:08:39 2010 +0200
+++ b/ChangeLog	Wed Jun 09 12:00:44 2010 +0200
@@ -1,6 +1,9 @@
 ChangeLog for RQL
 =================
 
+	--
+    * fix simplification bug with ored uid relations
+
 2010-06-04  --  0.26.1
     * normalize NOT() to NOT EXISTS() when it makes sense
 
--- a/stcheck.py	Mon Jun 07 13:08:39 2010 +0200
+++ b/stcheck.py	Wed Jun 09 12:00:44 2010 +0200
@@ -627,7 +627,8 @@
                 if key == 'uidrels':
                     constnode = relation.get_variable_parts()[1]
                     if not (relation.operator() != '=' or
-                            isinstance(relation.parent, Not)):
+                            isinstance(relation.parent, Not) or
+                            relation.parent.ored()):
                         if isinstance(constnode, Constant):
                             lhsvar.stinfo['constnode'] = constnode
                         lhsvar.stinfo['uidrel'] = relation
@@ -643,7 +644,6 @@
             if vref is rhs.children[0] and rschema.final:
                 update_attrvars(var, relation, lhs)
 
-
 def update_attrvars(var, relation, lhs):
     # stinfo['attrvars'] is set of couple (lhs variable name, relation name)
     # where the `var` attribute variable is used
--- a/test/unittest_stcheck.py	Mon Jun 07 13:08:39 2010 +0200
+++ b/test/unittest_stcheck.py	Wed Jun 09 12:00:44 2010 +0200
@@ -170,6 +170,12 @@
             # A eid 12 can be removed since the type analyzer checked its existence
             ('Any X WHERE A eid 12, X connait Y',
              'Any X WHERE X connait Y'),
+
+            ('Any X WHERE EXISTS(X work_for Y, Y eid 12) OR X eid 12',
+             'Any X WHERE (EXISTS(X work_for 12)) OR (X eid 12)'),
+
+            ('Any X WHERE EXISTS(X work_for Y, Y eid IN (12)) OR X eid IN (12)',
+             'Any X WHERE (EXISTS(X work_for 12)) OR (X eid 12)'),
             ):
             yield self._test_rewrite, rql, expected