2010-04-01 23:10:53 +08:00
|
|
|
from django.db.models.sql import compiler
|
|
|
|
|
|
|
|
class SQLCompiler(compiler.SQLCompiler):
|
|
|
|
def resolve_columns(self, row, fields=()):
|
|
|
|
values = []
|
2010-04-09 20:39:08 +08:00
|
|
|
index_extra_select = len(self.query.extra_select.keys())
|
|
|
|
for value, field in map(None, row[index_extra_select:], fields):
|
2012-03-01 01:46:23 +08:00
|
|
|
if (field and field.get_internal_type() in ("BooleanField", "NullBooleanField") and
|
|
|
|
value in (0, 1)):
|
|
|
|
value = bool(value)
|
|
|
|
values.append(value)
|
2010-04-09 20:39:08 +08:00
|
|
|
return row[:index_extra_select] + tuple(values)
|
2010-04-01 23:10:53 +08:00
|
|
|
|
|
|
|
class SQLInsertCompiler(compiler.SQLInsertCompiler, SQLCompiler):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class SQLDeleteCompiler(compiler.SQLDeleteCompiler, SQLCompiler):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class SQLUpdateCompiler(compiler.SQLUpdateCompiler, SQLCompiler):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class SQLAggregateCompiler(compiler.SQLAggregateCompiler, SQLCompiler):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class SQLDateCompiler(compiler.SQLDateCompiler, SQLCompiler):
|
|
|
|
pass
|