mirror of https://github.com/django/django.git
Fixed #10670: fixed reusing QuerySets previously used in a filter expression. Thanks, Alex Gaynor.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10357 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
751234bfd9
commit
25130b9675
|
@ -196,7 +196,7 @@ class BaseQuery(object):
|
|||
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])
|
||||
|
||||
|
|
|
@ -259,6 +259,23 @@ FieldError: Cannot resolve keyword 'foo' into field. Choices are: authors, conta
|
|||
>>> 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 @@ if settings.DATABASE_ENGINE != 'sqlite3':
|
|||
|
||||
|
||||
"""
|
||||
|
||||
|
|
Loading…
Reference in New Issue