[sql generation] fix exists table scope pb: when iterating other solutions inner to an EXISTS subquery, we should reset variables which have this exists node as scope stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 07 Mar 2011 17:17:07 +0100
branchstable
changeset 7042 8bcf33c493f8
parent 7041 5a6fd60f7617
child 7043 686010f3a83e
[sql generation] fix exists table scope pb: when iterating other solutions inner to an EXISTS subquery, we should reset variables which have this exists node as scope
server/sources/rql2sql.py
--- a/server/sources/rql2sql.py	Mon Mar 07 17:15:06 2011 +0100
+++ b/server/sources/rql2sql.py	Mon Mar 07 17:17:07 2011 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -365,6 +365,11 @@
             yield 1
             return
         thisexistssols, thisexistsvars = self.existssols[exists]
+        # when iterating other solutions inner to an EXISTS subquery, we should
+        # reset variables which have this exists node as scope at each iteration
+        for var in exists.stmt.defined_vars.itervalues():
+            if var.scope is exists:
+                thisexistsvars.add(var.name)
         origsol = self.solution
         origtables = self.tables
         done = self.done