#12608 closed (fixed)
Inconsistent results from values and values_list when using annotate
Reported by: | Matt McClanahan | Owned by: | coleifer |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | values_list annotate | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
To group users by email and get a count, one might do:
>>> User.objects.values('email').annotate(Count('email')) [{'email__count': 2, 'email': u'user@example.com'}]
However, values_list discards the annotated value:
>>> User.objects.values_list('email').annotate(Count('email')) [(u'user@example.com',)]
Attachments (2)
Change History (11)
comment:1 by , 15 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Keywords: | values_list annotate added |
comment:2 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 15 years ago
Has patch: | set |
---|
by , 15 years ago
Attachment: | 12608.patch added |
---|
comment:4 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 15 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:6 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
by , 15 years ago
Attachment: | 12608_fix.diff added |
---|
comment:8 by , 15 years ago
Note:
See TracTickets
for help on using tickets.
I patched the ValuesList iterator to include aggregates in the fields if specified: