rset.py
changeset 4951 7dc54e12c606
parent 4850 bd640b137f50
parent 4939 349af486f5ed
child 5072 072ae171aeb0
--- a/rset.py	Thu Mar 18 17:31:22 2010 +0100
+++ b/rset.py	Thu Mar 18 17:39:17 2010 +0100
@@ -287,12 +287,14 @@
             newselect = stmts.Select()
             newselect.limit = limit
             newselect.offset = offset
-            aliases = [nodes.VariableRef(newselect.get_variable(vref.name, i))
-                       for i, vref in enumerate(rqlst.selection)]
+            aliases = [nodes.VariableRef(newselect.get_variable(chr(65+i), i))
+                       for i in xrange(len(rqlst.children[0].selection))]
+            for vref in aliases:
+                newselect.append_selected(nodes.VariableRef(vref.variable))
             newselect.set_with([nodes.SubQuery(aliases, rqlst)], check=False)
             newunion = stmts.Union()
             newunion.append(newselect)
-            rql = rqlst.as_string(kwargs=self.args)
+            rql = newunion.as_string(kwargs=self.args)
             rqlst.parent = None
         return rql