Re: [Django] #14476: annotate, default aggregation naming and filter annoyance

16 views
Skip to first unread message

Django

unread,
May 21, 2011, 9:12:24 AM5/21/11
to django-...@googlegroups.com
#14476: annotate, default aggregation naming and filter annoyance
-------------------------------------+------------------------------------
Reporter: dirleyrls | Owner: ramiro
Type: Bug | Status: closed
Milestone: | Component: ORM aggregation
Version: 1.2 | Severity: Normal
Resolution: fixed | Keywords: annotate, FieldError
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 1
Patch needs improvement: 1 |
-------------------------------------+------------------------------------
Changes (by ramiro):

* status: new => closed
* owner: => ramiro
* resolution: => fixed


Comment:

In [16252]:
{{{
#!CommitTicketReference repository="" revision="16252"
Fixed #14476 -- Fixed resolution of automatically generated annotation
names so e.g. filtering based on them works. Thanks dirleyls for the
report and patch.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/14476#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 24, 2012, 1:04:16 AM1/24/12
to django-...@googlegroups.com
#14476: annotate, default aggregation naming and filter annoyance
--------------------------------------+------------------------------------
Reporter: dirleyrls | Owner: ramiro
Type: Bug | Status: reopened
Component: ORM aggregation | Version: 1.2
Severity: Normal | Resolution:
Keywords: annotate, FieldError | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by mrmachine):

* status: closed => reopened
* ui_ux: => 0
* resolution: fixed =>
* easy: => 0


Comment:

This is still a problem for aggregates.

{{{
>>> from django.contrib.auth.models import *
>>> from django.db.models import *
>>> User.objects.annotate(xyz=Count('groups')).aggregate(Max('xyz'))
{'xyz__max': 13}
>>> User.objects.annotate(Count('groups')).aggregate(Max('groups__count'))
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/mrmachine/django/db/models/query.py", line 331, in
aggregate
is_summary=True)
File "/Users/mrmachine/django/db/models/sql/query.py", line 1000, in
add_aggregate
field_list, opts, self.get_initial_alias(), False)
File "/Users/mrmachine/django/db/models/sql/query.py", line 1288, in
setup_joins
"Choices are: %s" % (name, ", ".join(names)))
FieldError: Cannot resolve keyword 'count' into field. Choices are: id,
name, permissions, user, groups__count
}}}

`exclude()`, `filter()`, `values()`, `values_list()` and `order_by()` all
work, so I assume that `aggregate()` should as well.

Can we apply the same fix? Let me know if I should open a new ticket
instead of re-opening this one.

--
Ticket URL: <https://code.djangoproject.com/ticket/14476#comment:5>

Django

unread,
Mar 11, 2013, 4:10:27 PM3/11/13
to django-...@googlegroups.com
#14476: annotate, default aggregation naming and filter annoyance
-------------------------------------+-------------------------------------

Reporter: dirleyrls | Owner: ramiro
Type: Bug | Status: reopened
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: annotate, | Needs documentation: 0
FieldError | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 1 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by fhahn):

* version: 1.2 => master
* component: ORM aggregation => Database layer (models, ORM)


--
Ticket URL: <https://code.djangoproject.com/ticket/14476#comment:6>

Django

unread,
Aug 6, 2015, 12:58:05 PM8/6/15
to django-...@googlegroups.com
#14476: annotate, default aggregation naming and filter annoyance
-------------------------------------+-------------------------------------
Reporter: dirleyrls | Owner: ramiro
Type: Bug | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: annotate, | Triage Stage: Accepted
FieldError |

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: new => closed

* resolution: => fixed


Comment:

That test case is fixed by f59fd15c4928caf3dfcbd50f6ab47be409a43b01
(Django 1.8). I will commit the test.

--
Ticket URL: <https://code.djangoproject.com/ticket/14476#comment:8>

Django

unread,
Aug 6, 2015, 1:53:03 PM8/6/15
to django-...@googlegroups.com
#14476: annotate, default aggregation naming and filter annoyance
-------------------------------------+-------------------------------------
Reporter: dirleyrls | Owner: ramiro
Type: Bug | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: annotate, | Triage Stage: Accepted
FieldError |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"3e1bb5cfb8f9676e0c045f0d101a094437133b54" 3e1bb5c]:
{{{
#!CommitTicketReference repository=""
revision="3e1bb5cfb8f9676e0c045f0d101a094437133b54"
Refs #14476 -- Added a test for default annotation name access in
aggregate.

Fixed in f59fd15c4928caf3dfcbd50f6ab47be409a43b01
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/14476#comment:9>

Reply all
Reply to author
Forward
0 new messages