fix subquery_selection_index responsability mess-up stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 09 Sep 2010 08:42:14 +0200
branchstable
changeset 579 341c6980df52
parent 578 2e878b60d581
child 580 6405b59a8355
fix subquery_selection_index responsability mess-up it wasn't doing what it should have done (see cw.rset related_entity implementation)
ChangeLog
stmts.py
--- a/ChangeLog	Thu Sep 09 08:39:10 2010 +0200
+++ b/ChangeLog	Thu Sep 09 08:42:14 2010 +0200
@@ -8,6 +8,9 @@
     * add constraint package to dependencies  so we've fallback opportunity if
       gecode is not installed
 
+    * fix subquery_selection_index responsability mess-up: it wasn't doing what
+      it should have done (see cw.rset related_entity implementation)
+
 2010-08-02  --  0.26.5
     * fix solutions computation crash with some query using sub-queries (closes #37423)
 
--- a/stmts.py	Thu Sep 09 08:39:10 2010 +0200
+++ b/stmts.py	Thu Sep 09 08:42:14 2010 +0200
@@ -327,14 +327,16 @@
         return self._subq_cache[(col, etype)]
 
     def subquery_selection_index(self, subselect, col):
-        """given a select sub-query and a column index in this sub-query, return
-        the selection index for this column in the root query
+        """given a select sub-query and a column index in the root query, return
+        the selection index for this column in the sub-query
         """
-        while col is not None and subselect.parent.parent:
+        selectpath = []
+        while subselect.parent.parent is not None:
             subq = subselect.parent.parent
             subselect = subq.parent
-            termvar = subselect.aliases[subq.aliases[col].name]
-            col = termvar.selected_index()
+            selectpath.insert(0, subselect)
+        for select in selectpath:
+            col = select.selection[col].variable.colnum
         return col
 
     # recoverable modification methods ########################################