#31377: Django 3.0: "GROUP BY" clauses error with tricky field annotation
-------------------------------------+-------------------------------------
     Reporter:  Holovashchenko       |                    Owner:  Hasan
  Vadym                              |  Ramezani
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  3.0
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:  group by, postgres,  |             Triage Stage:  Accepted
  annotate                           |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 Hasan this is another ''kind'' of collision, these fields are not selected
 and part of join tables so they won't be part of `names`.

 We can't change the behavior at the `annotate()` level as it would be
 backward incompatible and require extra checks every time an additional
 table is joined.

 What needs to be adjust is `sql.Query.set_group_by` to set `alias=None` if
 `alias is not None and alias in {... set of all column names of tables in
 alias_map ...}`.

 
https://github.com/django/django/blob/fc0fa72ff4cdbf5861a366e31cb8bbacd44da22d/django/db/models/sql/query.py#L1943-L1945

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31377#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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.c1ffcd6f14661964b797e06e7784061d%40djangoproject.com.

Reply via email to