1
0
mirror of https://github.com/django/django.git synced 2025-10-29 16:46:11 +00:00

Fixed #16409 -- Fixed an error condition when using QuerySet only()/defer() on the result of an annotate() call. Thanks jaklaassen AT gmail DOT com and Tai Lee for the reports and Tai for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16522 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Ramiro Morales
2011-07-07 01:12:45 +00:00
parent f5c9c2246e
commit b2050ff546
3 changed files with 9 additions and 4 deletions

View File

@@ -231,9 +231,6 @@ class QuerySet(object):
fields = self.model._meta.fields
pk_idx = self.model._meta.pk_index()
index_start = len(extra_select)
aggregate_start = index_start + len(self.model._meta.fields)
load_fields = []
# If only/defer clauses have been specified,
# build the list of fields that are to be loaded.
@@ -253,6 +250,9 @@ class QuerySet(object):
# Therefore, we need to load all fields from this model
load_fields.append(field.name)
index_start = len(extra_select)
aggregate_start = index_start + len(load_fields or self.model._meta.fields)
skip = None
if load_fields and not fill_cache:
# Some fields have been deferred, so we have to initialise