#30158: Subquery Expressions Incorrectly Added to Group by
-------------------------------------+-------------------------------------
     Reporter:  JonnyWaffles         |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  closed
    Component:  Database layer       |                  Version:  2.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  subquery, group_by   |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 I suspect `Subquery.get_group_by_cols` needs to be adjusted to return an
 empty list. Since #30099 (2.2a1+ only)
 
[https://github.com/django/django/blob/f021c110d02fd7ca32ae56f511b46e5d138b6c73/django/db/models/expressions.py#L334-L336
 it returns] `[self]` but before this change [it returned all the filter
 conditions with a left hand
 
side](https://github.com/django/django/blob/f021c110d02fd7ca32ae56f511b46e5d138b6c73/django/db/models/expressions.py#L1047-L1053)
 which is even worst.

 Could you try subclassing `Subquery` and overriding `get_group_by_cols` to
 `return []`, use the subclass with your query, and see if it helps?

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

Reply via email to