Created
January 30, 2015 07:04
-
-
Save loic/4b9f9b21fb54e2813f78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/django/db/models/query.py b/django/db/models/query.py | |
index ef0c2db..20edcd6 100644 | |
--- a/django/db/models/query.py | |
+++ b/django/db/models/query.py | |
@@ -886,16 +886,14 @@ class QuerySet(object): | |
if names is None: | |
names = {f.name for f in self.model._meta.get_fields()} | |
+ added_aggregates = False | |
for alias, annotation in annotations.items(): | |
if alias in names: | |
raise ValueError("The annotation '%s' conflicts with a field on " | |
"the model." % alias) | |
clone.query.add_annotation(annotation, alias, is_summary=False) | |
- | |
- added_aggregates = [] | |
- for alias, annotation in clone.query.annotations.items(): | |
- if alias in annotations and annotation.contains_aggregate: | |
- added_aggregates.append(alias) | |
+ if annotation.contains_aggregate: | |
+ added_aggregates = True | |
if added_aggregates: | |
if clone._fields is None: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment