summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2010-03-21 20:54:24 +0000
committerKaren Tracey <kmtracey@gmail.com>2010-03-21 20:54:24 +0000
commit740c97454167a17fbccedc6e775f3bb85904ec01 (patch)
tree21f95e8f7de4d573c25631f1d08db445a71f5c47 /django
parent3a55a2f42c95a008b11fff6ffca1b9859b95086b (diff)
[1.1.X] Fixed #12822: Don't copy the _aggregate_select_cache when cloning a query set,
as that can lead to incorrect SQL being generated for the query. Thanks to mat for the report and test, tobias for the fix, and Alex for review. r12830 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12831 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/db/models/sql/query.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 6b9f4b6d56..f09dc313bc 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -215,10 +215,12 @@ class BaseQuery(object):
obj.aggregate_select_mask = None
else:
obj.aggregate_select_mask = self.aggregate_select_mask.copy()
- if self._aggregate_select_cache is None:
- obj._aggregate_select_cache = None
- else:
- obj._aggregate_select_cache = self._aggregate_select_cache.copy()
+ # _aggregate_select_cache cannot be copied, as doing so breaks the
+ # (necessary) state in which both aggregates and
+ # _aggregate_select_cache point to the same underlying objects.
+ # It will get re-populated in the cloned queryset the next time it's
+ # used.
+ obj._aggregate_select_cache = None
obj.max_depth = self.max_depth
obj.extra = self.extra.copy()
if self.extra_select_mask is None: