Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #10670: fixed reusing QuerySets previously used in a filter exp…

…ression. Thanks, Alex Gaynor.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10357 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 25130b9675e5a53926ad45d828460341679d49fe 1 parent 751234b
@jacobian jacobian authored
View
3  django/db/models/sql/query.py
@@ -196,7 +196,7 @@ def clone(self, klass=None, **kwargs):
obj.distinct = self.distinct
obj.select_related = self.select_related
obj.related_select_cols = []
- obj.aggregates = self.aggregates.copy()
+ obj.aggregates = deepcopy(self.aggregates)
if self.aggregate_select_mask is None:
obj.aggregate_select_mask = None
else:
@@ -2366,4 +2366,3 @@ def add_to_dict(data, key, value):
data[key].add(value)
else:
data[key] = set([value])
-
View
18 tests/regressiontests/aggregation_regress/models.py
@@ -259,6 +259,23 @@ class Clues(models.Model):
>>> Book.objects.annotate(Count('publisher')).values('publisher').count()
6
+>>> publishers = Publisher.objects.filter(id__in=(1,2))
+>>> publishers
+[<Publisher: Apress>, <Publisher: Sams>]
+
+>>> publishers = publishers.annotate(n_books=models.Count('book'))
+>>> publishers[0].n_books
+2
+
+>>> publishers
+[<Publisher: Apress>, <Publisher: Sams>]
+
+>>> books = Book.objects.filter(publisher__in=publishers)
+>>> books
+[<Book: Practical Django Projects>, <Book: Sams Teach Yourself Django in 24 Hours>, <Book: The Definitive Guide to Django: Web Development Done Right>]
+
+>>> publishers
+[<Publisher: Apress>, <Publisher: Sams>]
"""
}
@@ -307,4 +324,3 @@ class Clues(models.Model):
"""
-
Please sign in to comment.
Something went wrong with that request. Please try again.