summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-06-06 06:14:05 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-06-06 06:14:05 +0000
commit512ee0f52889eb7f624f309cdc61fab57ab73a7b (patch)
treefe377b5550fbc3bb45f85f5c2d2d7530cc160f44 /django/db/models/sql
parent5b40ee32e6634f686c821ffa0dd5357c8dd85302 (diff)
Fixed #10572 -- Corrected the operation of the defer() and only() clauses when used on inherited models.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/query.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index d290d60e63..15b9fd6366 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -635,10 +635,10 @@ class BaseQuery(object):
# models.
workset = {}
for model, values in seen.iteritems():
- for field, f_model in model._meta.get_fields_with_model():
+ for field in model._meta.local_fields:
if field in values:
continue
- add_to_dict(workset, f_model or model, field)
+ add_to_dict(workset, model, field)
for model, values in must_include.iteritems():
# If we haven't included a model in workset, we don't add the
# corresponding must_include fields for that model, since an
@@ -657,6 +657,12 @@ class BaseQuery(object):
# included any fields, we have to make sure it's mentioned
# so that only the "must include" fields are pulled in.
seen[model] = values
+ # Now ensure that every model in the inheritance chain is mentioned
+ # in the parent list. Again, it must be mentioned to ensure that
+ # only "must include" fields are pulled in.
+ for model in orig_opts.get_parent_list():
+ if model not in seen:
+ seen[model] = set()
for model, values in seen.iteritems():
callback(target, model, values)