#34255: Annotation/group by with an expression on psycopg3
-------------------------------------+-------------------------------------
     Reporter:  Guillaume Andreu     |                    Owner:  nobody
  Sabater                            |
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:  orm postgres         |             Triage Stage:  Accepted
  psycopg3 annotation groupby        |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

 Just want to add that it also crashes without `ARRAY`, e.g. for a queryset
 from [https://code.djangoproject.com/ticket/34255#comment:1 comment:1]:
 {{{#!sql
 SELECT
     JSONB_BUILD_OBJECT(
         (%s)::text,
         EXTRACT(YEAR FROM "ticket_34255_point"."start_at" AT TIME ZONE
 %s),
         (%s)::text,
         AVG("ticket_34255_point"."value")
     ) AS "json"
 FROM "ticket_34255_point"
 GROUP BY
     EXTRACT(YEAR FROM "ticket_34255_point"."start_at" AT TIME ZONE %s)
 }}}
 {{{
 psycopg.errors.GroupingError: column "ticket_34255_point.start_at" must
 appear in the GROUP BY clause or be used in an aggregate function
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34255#comment:5>
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/01070185a98dcd99-a1ea281c-296b-4c02-8c35-96897804914d-000000%40eu-central-1.amazonses.com.

Reply via email to