[rset] fix crash while building entity from rset w/ some subquery. Closes #2089055 stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 16 Nov 2011 22:07:27 +0100
branchstable
changeset 8085 51929d531aff
parent 8081 e8091b415ad8
child 8086 a057a0a4371b
[rset] fix crash while building entity from rset w/ some subquery. Closes #2089055
rset.py
test/unittest_rset.py
--- a/rset.py	Thu Nov 10 23:18:56 2011 +0100
+++ b/rset.py	Wed Nov 16 22:07:27 2011 +0100
@@ -695,7 +695,7 @@
             continue
         if rootvar.name == rootmainvar.name:
             continue
-        if select is not rootselect:
+        if select is not rootselect and isinstance(rootvar, nodes.ColumnAlias):
             term = select.selection[root.subquery_selection_index(select, i)]
         var = _get_variable(term)
         if var is None:
--- a/test/unittest_rset.py	Thu Nov 10 23:18:56 2011 +0100
+++ b/test/unittest_rset.py	Wed Nov 16 22:07:27 2011 +0100
@@ -71,6 +71,13 @@
         result = list(attr_desc_iterator(select, col, 2))
         self.assertEqual(result, [])
 
+    def test_subquery_callfunc_2(self):
+        rql = ('Any X,S,L WHERE X in_state S WITH X, L BEING (Any X,MAX(L) GROUPBY X WHERE X is CWUser, T wf_info_for X, T creation_date L)')
+        rqlst = parse(rql)
+        select, col = rqlst.locate_subquery(0, 'CWUser', None)
+        result = list(attr_desc_iterator(select, col, 0))
+        self.assertEqual(result, [(1, 'in_state', 'subject')])
+
 
 class ResultSetTC(CubicWebTC):
 
@@ -479,5 +486,6 @@
         self.assertIsInstance(str(rset), basestring)
         self.assertEqual(len(str(rset).splitlines()), 1)
 
+
 if __name__ == '__main__':
     unittest_main()