Opened 16 years ago

Last modified 12 years ago

#10132 closed

QuerySet values() should work on extra(select) fields — at Initial Version

Reported by: Glenn Maynard Owned by:
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

From http://groups.google.com/group/django-users/browse_frm/thread/15b3c24dddd2a2d5/2214eba4328126ca

Item.objects.extra(select={"note_alias": "note"}).values("note_alias").annotate(Count("id")).order_by('note_id')

generates:

SELECT (note_id) AS "note_alias", U0."id", COUNT("queries_item"."id") AS "idcount" FROM "queries_item" U0 GROUP BY "queries_item"."id", "queries_item"."name", "queries_item"."created", "queries_item"."modified", "queries_item"."creator_id", "queries_item"."note_id"

but should (possibly) generate:

SELECT (note_id) AS "note_alias", COUNT("queries_item"."id") AS "idcount" FROM queries_item GROUP BY note_alias ORDER BY note_id

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top