diff options
Diffstat (limited to 'lib/python2.7/site-packages/django/db/backends/mysql/compiler.py')
-rw-r--r-- | lib/python2.7/site-packages/django/db/backends/mysql/compiler.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/python2.7/site-packages/django/db/backends/mysql/compiler.py b/lib/python2.7/site-packages/django/db/backends/mysql/compiler.py new file mode 100644 index 0000000..d3439bf --- /dev/null +++ b/lib/python2.7/site-packages/django/db/backends/mysql/compiler.py @@ -0,0 +1,37 @@ +from django.db.models.sql import compiler +from django.utils.six.moves import zip_longest + + +class SQLCompiler(compiler.SQLCompiler): + def resolve_columns(self, row, fields=()): + values = [] + index_extra_select = len(self.query.extra_select) + for value, field in zip_longest(row[index_extra_select:], fields): + if (field and field.get_internal_type() in ("BooleanField", "NullBooleanField") and + value in (0, 1)): + value = bool(value) + values.append(value) + return row[:index_extra_select] + tuple(values) + + def as_subquery_condition(self, alias, columns, qn): + qn2 = self.connection.ops.quote_name + sql, params = self.as_sql() + return '(%s) IN (%s)' % (', '.join(['%s.%s' % (qn(alias), qn2(column)) for column in columns]), sql), params + +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 + +class SQLDateTimeCompiler(compiler.SQLDateTimeCompiler, SQLCompiler): + pass |