#25414: invalid annotate query for mysql when primary key is included
-------------------------------------+-------------------------------------
     Reporter:  svniemeijer          |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  mysql, annotate      |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by charettes):

 * needs_docs:   => 0
 * needs_better_patch:   => 0
 * version:  1.8 => master
 * needs_tests:   => 0
 * stage:  Unreviewed => Accepted


Comment:

 I didn't reproduce but by looking at
 
[https://github.com/django/django/blob/233b46f93171d4a7cc279bc3f35e5a99e9a167b8/django/db/models/sql/compiler.py#L136-L154
 collapse_group_by()'s MySQL special casing] I can see how this is an
 issue.

 On MySQL the existing code collapse the `GROUP BY` clause to the queryset
 model's primary key if it's present. It should also account for
 expressions referring to aliases other than the initial table just like
 the branch for PostgreSQL does.

--
Ticket URL: <https://code.djangoproject.com/ticket/25414#comment:1>
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/069.4477024077ba75bc4c0f407e41b68908%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to