Opened 17 years ago
Closed 17 years ago
#7256 closed (fixed)
extra() does not play well with values()
Reported by: | Nicolas Lara | Owned by: | Nicolas Lara |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | qsrf-cleanup extra values | |
Cc: | jdunck@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When using extra() on a ValuesQuerySet or aplying values to a queryset with extra_select, the selection done by extra() is not preserved
>>> Book.objects.all().values().extra(select={'price_per_page' : 'price / pages'}).get(pk=1) {'id': 1, 'isbn': u'159059725', 'name': u' The Definitive Guide to Django: Web Development Done Right', 'pages': 447, 'price': 30.0, 'publisher_id': 1} >>> Book.objects.all().extra(select={'price_per_page' : 'price / pages'}).values().get(pk=1) {'id': 1, 'isbn': u'159059725', 'name': u' The Definitive Guide to Django: Web Development Done Right', 'pages': 447, 'price': 30.0, 'publisher_id': 1}
while:
>>> Book.objects.all().extra(select={'price_per_page' : 'price / pages'}).get(pk=1).__dict__ {'id': 1, 'isbn': u'159059725', 'name': u' The Definitive Guide to Django: Web Development Done Right', 'pages': 447, 'price': 30.0, 'price_per_page': 0.067114093959731502, 'publisher_id': 1}
I am assigning the ticket to myself, but wont work on it until after aggregation is stable (also im waiting for it to be 'Accepted').
Attachments (1)
Change History (6)
comment:1 by , 17 years ago
Keywords: | qsrf-cleanup added |
---|
comment:2 by , 17 years ago
Has patch: | set |
---|
I was about to un-claim the ticket but decided to check the code a bit before doing it. Turns out it was a really simple fix.
by , 17 years ago
Attachment: | extra_values.diff added |
---|
comment:3 by , 17 years ago
Cc: | added |
---|
comment:4 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Marking as qsrf-cleanup since it seems to be a problem introduced with the QSRF changes. Just getting more eyes on DB-related stuff.