#30158: Subquery expressions unnecessarily added to group by
-------------------------------------+-------------------------------------
     Reporter:  Jonny Fuller         |                    Owner:  Simon
         Type:                       |  Charette
  Cleanup/optimization               |                   Status:  assigned
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  subquery, group_by   |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 I renamed the ticket because I'm pretty confident that the generated query
 doesn't cause the wrong results to be returned.

 The fact that the ORM doesn't have the introspection abilities to
 determine if some annotated expressions can be trimmed from the `GROUP BY`
 clause on aggregation
 
[https://github.com/django/django/blob/5c17c273ae2d7274f1fa78218b3b74690efddb86/django/db/models/sql/query.py#L407-L409
 is a known limitation] and there's probably other existing issues for
 other type of expressions.

 Since the initial approach of making `get_group_by_cols` return an empty
 list is not viable for the aforementioned reason I think we should begin
 by merging [https://github.com/django/django/pull/11030 regression tests
 to prevent this edge case from being overlooked in the future].

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30158#comment:13>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/070.e08303ff503ae7a9d57a95c2f7bad39b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to