#36647: Annotation with Coalesce subquery unexpectedly included in group by
-------------------------------------+-------------------------------------
     Reporter:  Joseph Yu            |                    Owner:  (none)
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

 * cc: Simon Charette (added)
 * resolution:   => invalid
 * status:  new => closed

Comment:

 Hello Joseph Yu, thank you for your ticket. Can you please confirm
 behavior using a supported version of Django (4.2 is on security-
 maintenance mode only)? Ideally, using latest `main`, if that's not
 possible, or trying 6.0a1 or 5.2 otherwise. Also, could you please provide
 a fully functional and runnable Python/Django snippet? We would appreciate
 if you ensure that your models inherit from `models.Model` and that every
 necessary import is included.

 As for the observed behavior, I understand that this happens because of
 how Django's ORM determines which expressions must be included in the SQL
 `GROUP BY` when both aggregation and non-aggregate annotations are
 present. After a `.values()` call, Django uses the selected fields to
 define the grouping. When a second `.annotate()` adds an expression such
 the one proposed, the ORM treats it as a computed expression that may
 depend on grouped columns.

 Having said all the above, I think this report seems better suited to be a
 support request. The best place to get answers to your issue is using any
 of the user support channels from
 [https://docs.djangoproject.com/en/dev/faq/help/#how-do-i-do-x-why-
 doesn-t-y-work-where-can-i-go-to-get-help this link].

 Since the goal of this issue tracker is to track confirmed issues about
 Django itself, I'll be closing this ticket as `invalid` following the
 [https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
 tickets/#closing-tickets ticket triaging process]. If, after consultation
 in the Django Forum, you find out that this is indeed a bug in Django,
 please re-open with the specific details.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36647#comment:1>
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 visit 
https://groups.google.com/d/msgid/django-updates/01070199c60948d9-5e31bc43-bfe9-4f43-a1b5-67f14d456ef3-000000%40eu-central-1.amazonses.com.

Reply via email to