diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-02-03 11:07:21 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-02-03 11:07:21 +0000 |
| commit | ecadf675690c2cc9375e9af70ebd1528841eae76 (patch) | |
| tree | b2470a54ac83e70e285c4f465c832a298cc8fb9d /django | |
| parent | a008b5c9abae582ca31578ff7d6842d0d6b00e27 (diff) | |
Fixed #10127 -- Corrected (no, really, this time!) the way the select_related() cache is populated when annotations are also contained in the query. Thanks to Sylvain Pasche <sylvain.pasche@gmail.com> for the report and test case.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9808 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/query.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index aa2034919c..e33a858a81 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -281,7 +281,8 @@ class QuerySet(object): for row in self.query.results_iter(): if fill_cache: obj, _ = get_cached_row(self.model, row, - index_start, max_depth, requested=requested) + index_start, max_depth, + requested=requested, offset=len(aggregate_select)) else: # omit aggregates in object creation obj = self.model(*row[index_start:aggregate_start]) @@ -898,7 +899,7 @@ class EmptyQuerySet(QuerySet): def get_cached_row(klass, row, index_start, max_depth=0, cur_depth=0, - requested=None): + requested=None, offset=0): """ Helper function that recursively returns an object with the specified related attributes already populated. @@ -915,6 +916,7 @@ def get_cached_row(klass, row, index_start, max_depth=0, cur_depth=0, obj = None else: obj = klass(*fields) + index_end += offset for f in klass._meta.fields: if not select_related_descend(f, restricted, requested): continue |
