diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2013-10-01 11:07:41 +0300 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-10-01 20:29:23 +0300 |
| commit | bf13c75c0d94d606b8a077ff73bbd0440f05b396 (patch) | |
| tree | 89f6f47f99e06fab29384c22c9741c5e0ab8d124 /django/db/models/sql | |
| parent | 0d02c5429970804068520f0dc6f0ae9fb3e08b9c (diff) | |
Fixed #21203 -- resolve_columns fields misalignment
In queries using .defer() together with .select_related() the values
and fields arguments didn't align properly for resolve_columns().
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/compiler.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 4a08b1fc14..3707348968 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -713,9 +713,8 @@ class SQLCompiler(object): # into `resolve_columns` because it wasn't selected. only_load = self.deferred_to_columns() if only_load: - db_table = self.query.get_meta().db_table - fields = [f for f in fields if db_table in only_load and - f.column in only_load[db_table]] + fields = [f for f in fields if f.model._meta.db_table not in only_load or + f.column in only_load[f.model._meta.db_table]] if has_aggregate_select: # pad None in to fields for aggregates fields = fields[:aggregate_start] + [ |
