#30209: Union with group by don't generate correct Subquery
-------------------------------------+-------------------------------------
     Reporter:  Nikolas              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  union, group by      |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  1
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 > I'm not sure what exception class should be used here. TypeError?
 Thoughts?

 Good question. I know that
 [https://docs.djangoproject.com/en/2.1/ref/models/querysets/#union we're
 currently preventing some operations on combined querysets] so I'd try to
 see what type of exception we're currently raising and stick to it to be
 coherent. I think `.filter()` is disallowed for example. It's possible
 that we simply crash though.

 I think the best place to add this check would be in
 `query.Queryset.annotate` just before `set_group_by`
 
[https://github.com/django/django/blob/418263c457636d3301f2068c47f09a0f42e15c52/django/db/models/query.py#L1052
 is called] if an annotation contains aggregates.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30209#comment:8>
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/069.a15c14228d4ada6ed604db5050c929a7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to