summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-04-01 15:10:53 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-04-01 15:10:53 +0000
commit271bcda04af23bd4deb9656edd59038537f301c5 (patch)
tree121b6e87e14f4dac6f11cc78456c6fd09ddfa6d3 /django
parent2fa2cf0a092816bfd92ff5e94907f5bca8f3c365 (diff)
Fixed #7190 -- Corrected a problem with Boolean value handling on the MySQL backend. Thanks to George Vilches for the initial patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12900 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/mysql/base.py2
-rw-r--r--django/db/backends/mysql/compiler.py27
2 files changed, 29 insertions, 0 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 2a5acad0c0..66c13ed035 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -125,6 +125,8 @@ class DatabaseFeatures(BaseDatabaseFeatures):
related_fields_match_type = True
class DatabaseOperations(BaseDatabaseOperations):
+ compiler_module = "django.db.backends.mysql.compiler"
+
def date_extract_sql(self, lookup_type, field_name):
# http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html
if lookup_type == 'week_day':
diff --git a/django/db/backends/mysql/compiler.py b/django/db/backends/mysql/compiler.py
new file mode 100644
index 0000000000..07832f27f0
--- /dev/null
+++ b/django/db/backends/mysql/compiler.py
@@ -0,0 +1,27 @@
+from django.db.models.sql import compiler
+
+class SQLCompiler(compiler.SQLCompiler):
+ def resolve_columns(self, row, fields=()):
+ values = []
+ for value, field in map(None, row, fields):
+ if (field and field.get_internal_type() in ("BooleanField", "NullBooleanField") and
+ value in (0, 1)):
+ value = bool(value)
+ values.append(value)
+ return tuple(values)
+
+
+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