#32478: Queryset annotation mixing aggregate and subquery doesn't GROUP BY outer
column references.
-------------------------------------+-------------------------------------
     Reporter:  Igor Pejic           |                    Owner:  Simon
                                     |  Charette
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  3.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  outerref, subquery   |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * owner:  nobody => Simon Charette
 * status:  new => assigned
 * stage:  Unreviewed => Accepted


Comment:

 That looks like another case of #31094 but generalized for expressions
 that mix aggregates and subqueries.

 `Case.get_group_by_cols()` defers to `BaseExpression.get_group_by_cols()`
 when it has `cases` and the latter immediately returns `self`
 
[https://github.com/django/django/blob/19ce1d493ae7cbc1e704d338077b1f5f5e5769c9/django/db/models/expressions.py#L349-L355
 when it contains aggregates].

 Igor, could you include the SQL that uses to be generated and what the new
 one looks like?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32478#comment:4>
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/067.9c53373bf0c2ec057bcb01003a02bec2%40djangoproject.com.

Reply via email to