server/rqlannotation.py
branchstable
changeset 7041 5a6fd60f7617
parent 6940 1172c25655b7
child 7193 7eaef037ea9d
--- 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