diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2012-10-26 00:25:59 +0100 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2012-10-26 00:25:59 +0100 |
| commit | f3a2bcdee906f7ca1434b6275fdc09b3a454cf46 (patch) | |
| tree | ffde68141a87e4982d991737e9c1644c35f7da27 /django/db/models/sql/compiler.py | |
| parent | 5c143cb340df6825714a6317901b6df03d4ef4b0 (diff) | |
Fixed #15040 - Boolean fields return 0 and 1 when loaded through select_related
Thanks to homm for the report and ramiro for the patch.
Diffstat (limited to 'django/db/models/sql/compiler.py')
| -rw-r--r-- | django/db/models/sql/compiler.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index a68f6e0290..b9095e503a 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -774,10 +774,20 @@ class SQLCompiler(object): # We only set this up here because # related_select_fields isn't populated until # execute_sql() has been called. + + # We also include types of fields of related models that + # will be included via select_related() for the benefit + # of MySQL/MySQLdb when boolean fields are involved + # (#15040). + + # This code duplicates the logic for the order of fields + # found in get_columns(). It would be nice to clean this up. if self.query.select_fields: - fields = self.query.select_fields + self.query.related_select_fields + fields = self.query.select_fields else: fields = self.query.model._meta.fields + fields = fields + self.query.related_select_fields + # If the field was deferred, exclude it from being passed # into `resolve_columns` because it wasn't selected. only_load = self.deferred_to_columns() |
