1
0
mirror of https://github.com/django/django.git synced 2025-10-29 16:46:11 +00:00

Fixed #14476 -- Fixed resolution of automatically generated annotation names so e.g. filtering based on them works. Thanks dirleyls for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16252 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Ramiro Morales
2011-05-21 13:12:23 +00:00
parent 803a454aef
commit 15793309e1
2 changed files with 35 additions and 8 deletions

View File

@@ -1053,14 +1053,14 @@ class Query(object):
value = SQLEvaluator(value, self)
having_clause = value.contains_aggregate
if parts[0] in self.aggregates:
aggregate = self.aggregates[parts[0]]
entry = self.where_class()
entry.add((aggregate, lookup_type, value), AND)
if negate:
entry.negate()
self.having.add(entry, connector)
return
for alias, aggregate in self.aggregates.items():
if alias in (parts[0], LOOKUP_SEP.join(parts)):
entry = self.where_class()
entry.add((aggregate, lookup_type, value), AND)
if negate:
entry.negate()
self.having.add(entry, connector)
return
opts = self.get_meta()
alias = self.get_initial_alias()