#23557: Prevent silent extension of explicit GROUP BY when using order_by
-------------------------------------+-------------------------------------
     Reporter:  Brian May            |                    Owner:  ontowhee
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  1.7
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by ontowhee):

 * has_patch:  0 => 1
 * needs_better_patch:  0 => 1
 * owner:  nobody => ontowhee
 * status:  new => assigned

Comment:

 I opened a [https://github.com/django/django/pull/19536 draft pr]. It is
 still a work in progress and quite incomplete. I've looked into Postgres
 only so far.

 There are a couple of items that still need to be addressed:
 - Handle ordering by primary keys, including composite pks. There is
 existing support for ordering by primary keys for some databases, so it
 seems we should allow ordering by pk even if it is not included in the
 select list. Does this sound right? My thought is to get a list of pks
 across all table involved in the query and use that to compare against the
 columns from order by that are being added to group by. I'm not exactly
 sure how to get the models and their pks yet, but I'll dig around.
 - Handle ordering by annotations, including when the annotations get
 reduced to pks in the group by clause. Similar to above, I'll dig around
 to see how this can be done.

 Does this sound like it is heading in the right direction?
-- 
Ticket URL: <https://code.djangoproject.com/ticket/23557#comment:11>
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 visit 
https://groups.google.com/d/msgid/django-updates/0107019749345a97-291e7251-a99a-4ea0-b7b8-b124ac95ea78-000000%40eu-central-1.amazonses.com.

Reply via email to