#34464: QuerySet.count() regression on Django 4.2 with values() and annotate()
-------------------------------------+-------------------------------------
     Reporter:  Ian Cubitt           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:  postgresql           |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

 Django 4.1:
 {{{#!sql
 SELECT COUNT(*) FROM (
     SELECT
         DATE_TRUNC('hour',
 "ticket_34464_samplemodel"."sample_datetime_field") AS "hour",
         COUNT(*) AS "hour_count"
     FROM "ticket_34464_samplemodel"
     GROUP BY
         DATE_TRUNC('hour',
 "ticket_34464_samplemodel"."sample_datetime_field")
     HAVING COUNT(*) >= 5
 ) subquery
 }}}
 Django 4.2:
 {{{#!sql
 SELECT COUNT(*) FROM (
     SELECT
         "ticket_34464_samplemodel"."id" AS "col1"
     FROM "ticket_34464_samplemodel"
     GROUP BY
         DATE_TRUNC('hour',
 "ticket_34464_samplemodel"."sample_datetime_field"),
         1
     HAVING COUNT(*) >= 5
 ) subquery
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34464#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018755a5f997-1a740126-6491-400e-85fc-9749e2e20a88-000000%40eu-central-1.amazonses.com.

Reply via email to