#32658: Subquery ignores query ordering
-------------------------------------+-------------------------------------
Reporter: Bálint Balina | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: Subquery, | Triage Stage:
annotations, ordering | 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 this case I think we should either make the logic in charge of clearing
ordering consider `contains_aggregate` as well.
An alternative which might more correct would be to move the ordering
clearing logic to `In(Lookup).process_rhs` after all
[https://github.com/django/django/blob/aa4acc164d1247c0de515c959f7b09648b57dc42/django/db/models/lookups.py#L399
that's what we do for clearing the select clause]. The devils lurks in the
details there though as the solution needs to handle `Subquery`,
`sql.Query`, and `QuerySet` (all resolves to `sql.Query` though) right-
hand-sides and the ordering can only be cleared
[https://github.com/django/django/blob/678c8dfee458cda77fce0d1c127f1939dc134584/django/db/models/sql/query.py#L1029-L1034
under some particular conditions].
Maybe adding a `sql.Query.as_haystack` (please suggest a better name)
method that takes care of all this logic and duck-typing against it in
`In(Lookup).process_rhs` would provide a decoupled enough API?
--
Ticket URL: <https://code.djangoproject.com/ticket/32658#comment:4>
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/075.2e480895bb012ad98796fbc6ed10cacf%40djangoproject.com.