rset.py
changeset 4951 7dc54e12c606
parent 4850 bd640b137f50
parent 4939 349af486f5ed
child 5072 072ae171aeb0
equal deleted inserted replaced
4945:356662a6f06c 4951:7dc54e12c606
   285             select.limit, select.offset = olimit, ooffset
   285             select.limit, select.offset = olimit, ooffset
   286         else:
   286         else:
   287             newselect = stmts.Select()
   287             newselect = stmts.Select()
   288             newselect.limit = limit
   288             newselect.limit = limit
   289             newselect.offset = offset
   289             newselect.offset = offset
   290             aliases = [nodes.VariableRef(newselect.get_variable(vref.name, i))
   290             aliases = [nodes.VariableRef(newselect.get_variable(chr(65+i), i))
   291                        for i, vref in enumerate(rqlst.selection)]
   291                        for i in xrange(len(rqlst.children[0].selection))]
       
   292             for vref in aliases:
       
   293                 newselect.append_selected(nodes.VariableRef(vref.variable))
   292             newselect.set_with([nodes.SubQuery(aliases, rqlst)], check=False)
   294             newselect.set_with([nodes.SubQuery(aliases, rqlst)], check=False)
   293             newunion = stmts.Union()
   295             newunion = stmts.Union()
   294             newunion.append(newselect)
   296             newunion.append(newselect)
   295             rql = rqlst.as_string(kwargs=self.args)
   297             rql = newunion.as_string(kwargs=self.args)
   296             rqlst.parent = None
   298             rqlst.parent = None
   297         return rql
   299         return rql
   298 
   300 
   299     def limit(self, limit, offset=0, inplace=False):
   301     def limit(self, limit, offset=0, inplace=False):
   300         """limit the result set to the given number of rows optionaly starting
   302         """limit the result set to the given number of rows optionaly starting