Changes between Initial Version and Version 1 of Ticket #10132


Ignore:
Timestamp:
Jan 27, 2009, 1:23:26 AM (16 years ago)
Author:
Malcolm Tredinnick
Comment:

Fixed description formatting.

Also changed the title to reflect the problem. The extra() and values() methods already work together. It's only the final call to add aggregation in that is triggering this.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #10132

    • Property Summary QuerySet values() should work on extra(select) fieldsAggregations add extra values to ValuesQuerySets
  • Ticket #10132 – Description

    initial v1  
    11From http://groups.google.com/group/django-users/browse_frm/thread/15b3c24dddd2a2d5/2214eba4328126ca
    2 
     2{{{
     3#!python
    34Item.objects.extra(select={"note_alias": "note"}).values("note_alias").annotate(Count("id")).order_by('note_id')
    4 
     5}}}
    56generates:
    6 
    7 SELECT (note_id) AS "note_alias", U0."id", COUNT("queries_item"."id") AS "id__count" 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"
     7{{{
     8#!sql
     9SELECT (note_id) AS "note_alias", U0."id",
     10COUNT("queries_item"."id") AS "id__count" FROM "queries_item" U0
     11GROUP BY "queries_item"."id", "queries_item"."name",
     12"queries_item"."created", "queries_item"."modified",
     13"queries_item"."creator_id", "queries_item"."note_id"
     14}}}
    815
    916but should (possibly) generate:
    10 
    11 SELECT (note_id) AS "note_alias", COUNT("queries_item"."id") AS "id__count" FROM queries_item GROUP BY note_alias ORDER BY note_id
     17{{{
     18#!sql
     19SELECT (note_id) AS "note_alias",
     20COUNT("queries_item"."id") AS "id__count" FROM queries_item
     21 GROUP BY note_alias ORDER BY note_id
     22}}}
Back to Top