Changes between Initial Version and Version 1 of Ticket #19493


Ignore:
Timestamp:
Dec 18, 2012, 7:17:23 AM (12 years ago)
Author:
Anssi Kääriäinen
Comment:

What SQL do you get? settings.DEBUG = True + connection.queries should tell you the executed query easily.

Quickly checking it seems a QuerySet with multiple rows having someintegerfield__count=1 seems the correct answer for the query.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #19493 – Description

    initial v1  
    22models.SomeModel.objects.filter(somecharfield=value).values("someintegerfield").annotate(Count("someintegerfield"))
    33
    4 return a QuerySet with no aggregate count, but multiple rows with someintegerfield__count=1
     4return a QuerySet with no aggregate count, but multiple rows with `someintegerfield__count=1`
    55
    6 The correct SQL would be: SELECT tablespace_somemodel.someintegerfield,COUNT(tablespace_somemodel.someintegerfield) AS someintegerfield__count FROM tablespace_somemodel WHERE tablespace_somemodel.somecharfield = 'value'  GROUP BY tablespace_somemodel.someintegerfield;
     6The correct SQL would be:
     7{{{
     8SELECT tablespace_somemodel.someintegerfield, COUNT(tablespace_somemodel.someintegerfield) AS someintegerfield__count
     9  FROM tablespace_somemodel WHERE tablespace_somemodel.somecharfield = 'value'
     10 GROUP BY tablespace_somemodel.someintegerfield;
     11}}}
    712
    813This works fine on other backends.
Back to Top