# HG changeset patch # User Sylvain Thénault # Date 1299514506 -3600 # Node ID 5a6fd60f76170785d6d125b5fcbf1f760fc6bac5 # Parent df0e8581b06f99c28e10668427a1e02b2344756f [sql generation] fix table scope pb: when an inlined relation is used as principal for the rhs variable, we should adjust lhs variable'scope diff -r df0e8581b06f -r 5a6fd60f7617 server/rqlannotation.py --- a/server/rqlannotation.py Mon Mar 07 10:41:04 2011 +0100 +++ b/server/rqlannotation.py Mon Mar 07 17:15:06 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