Created
September 19, 2013 16:03
-
-
Save manfre/6625675 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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