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