|
29
|
1 |
from django.db.models.sql import compiler |
|
|
2 |
|
|
|
3 |
class SQLCompiler(compiler.SQLCompiler): |
|
|
4 |
def resolve_columns(self, row, fields=()): |
|
|
5 |
values = [] |
|
|
6 |
index_extra_select = len(self.query.extra_select.keys()) |
|
|
7 |
for value, field in map(None, row[index_extra_select:], fields): |
|
|
8 |
if (field and field.get_internal_type() in ("BooleanField", "NullBooleanField") and |
|
|
9 |
value in (0, 1)): |
|
|
10 |
value = bool(value) |
|
|
11 |
values.append(value) |
|
|
12 |
return row[:index_extra_select] + tuple(values) |
|
|
13 |
|
|
|
14 |
class SQLInsertCompiler(compiler.SQLInsertCompiler, SQLCompiler): |
|
|
15 |
pass |
|
|
16 |
|
|
|
17 |
class SQLDeleteCompiler(compiler.SQLDeleteCompiler, SQLCompiler): |
|
|
18 |
pass |
|
|
19 |
|
|
|
20 |
class SQLUpdateCompiler(compiler.SQLUpdateCompiler, SQLCompiler): |
|
|
21 |
pass |
|
|
22 |
|
|
|
23 |
class SQLAggregateCompiler(compiler.SQLAggregateCompiler, SQLCompiler): |
|
|
24 |
pass |
|
|
25 |
|
|
|
26 |
class SQLDateCompiler(compiler.SQLDateCompiler, SQLCompiler): |
|
|
27 |
pass |