Skip to content

Instantly share code, notes, and snippets.

@manfre
Created September 19, 2013 16:03
Show Gist options
  • Save manfre/6625675 to your computer and use it in GitHub Desktop.
Save manfre/6625675 to your computer and use it in GitHub Desktop.
class SQLCompiler(compiler.SQLCompiler):
def resolve_columns(self, row, fields=()):
# If the results are sliced, the resultset will have an initial
# "row number" column. Remove this column before the ORM sees it.
if getattr(self, '_using_row_number', False):
row = row[1:]
values = []
index_extra_select = len(self.query.extra_select.keys())
for value, field in map(None, row[index_extra_select:], fields):
if field:
try:
val = self.connection.ops.convert_values(value, field)
except ValueError:
val = value
values.append(val)
return row[:index_extra_select] + tuple(values)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment