backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 07 Mar 2011 17:19:29 +0100
changeset 7044 7279de21df34
parent 7040 9b1f9bc74f5d (current diff)
parent 7043 686010f3a83e (diff)
child 7045 0f30e4f1ee5a
backport stable
server/test/unittest_querier.py
--- a/server/rqlannotation.py	Mon Mar 07 17:02:15 2011 +0100
+++ b/server/rqlannotation.py	Mon Mar 07 17:19:29 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.
@@ -135,7 +135,12 @@
             # priority should be given to relation which are not in inner queries
             # (eg exists)
             try:
-                stinfo['principal'] = _select_principal(var.scope, joins)
+                stinfo['principal'] = principal = _select_principal(var.scope, joins)
+                if getrschema(principal.r_type).inlined:
+                    # the scope of the lhs variable must be equal or outer to the
+                    # rhs variable's scope (since it's retrieved from lhs's table)
+                    sstinfo = principal.children[0].variable.stinfo
+                    sstinfo['scope'] = common_parent(sstinfo['scope'], stinfo['scope']).scope
             except CantSelectPrincipal:
                 stinfo['invariant'] = False
     rqlst.need_distinct = need_distinct
--- a/server/sources/rql2sql.py	Mon Mar 07 17:02:15 2011 +0100
+++ b/server/sources/rql2sql.py	Mon Mar 07 17:19:29 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
--- a/server/test/unittest_querier.py	Mon Mar 07 17:02:15 2011 +0100
+++ b/server/test/unittest_querier.py	Mon Mar 07 17:19:29 2011 +0100
@@ -1,5 +1,5 @@
 # -*- coding: iso-8859-1 -*-
-# 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.
--- a/server/test/unittest_rql2sql.py	Mon Mar 07 17:02:15 2011 +0100
+++ b/server/test/unittest_rql2sql.py	Mon Mar 07 17:19:29 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.