# HG changeset patch # User Sylvain Thénault # Date 1299514769 -3600 # Node ID 7279de21df34de9384c1140dceb6dda2be9bcc0a # Parent 9b1f9bc74f5d99c506629fbfff1d3fe0933ab7ff# Parent 686010f3a83ed0f9fe9768fc38a17241fb672241 backport stable diff -r 9b1f9bc74f5d -r 7279de21df34 server/rqlannotation.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 diff -r 9b1f9bc74f5d -r 7279de21df34 server/sources/rql2sql.py --- 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 diff -r 9b1f9bc74f5d -r 7279de21df34 server/test/unittest_querier.py --- 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. diff -r 9b1f9bc74f5d -r 7279de21df34 server/test/unittest_rql2sql.py --- 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.