1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #27481 -- Made SQLite return annotated boolean values as boolean, not integer.

Thanks Simon Charette for review.
This commit is contained in:
Sergey Fedoseev
2016-11-15 01:47:20 +06:00
committed by Tim Graham
parent 967be82443
commit c7bfcd2f37
2 changed files with 18 additions and 1 deletions

View File

@@ -209,6 +209,8 @@ class DatabaseOperations(BaseDatabaseOperations):
converters.append(self.convert_decimalfield_value)
elif internal_type == 'UUIDField':
converters.append(self.convert_uuidfield_value)
elif internal_type in ('NullBooleanField', 'BooleanField'):
converters.append(self.convert_booleanfield_value)
return converters
def convert_datetimefield_value(self, value, expression, connection, context):
@@ -242,6 +244,9 @@ class DatabaseOperations(BaseDatabaseOperations):
value = uuid.UUID(value)
return value
def convert_booleanfield_value(self, value, expression, connection, context):
return bool(value) if value in (1, 0) else value
def bulk_insert_sql(self, fields, placeholder_rows):
return " UNION ALL ".join(
"SELECT %s" % ", ".join(row)