#37097: Nested double-unioned query for model with ordering fails on
Postgres/MySql
-------------------------------------+-------------------------------------
Reporter: Shai Berger | Owner: Jacob
| Walls
Type: Bug | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
When an `__in` lookup is used
[https://github.com/django/django/blob/335c6d0129400eda792f3bec5c71bb28af5e5d37/django/db/models/lookups.py#L508
we explicitly clear the ordering as it's unnecessary] (including the
default one).
This problem made me think of your initial approach at making
`Query.clear_ordering` [https://github.com/django/django/pull/21247/
somewhat recursive] Jacob. Should we instead consider making the following
changes instead?
{{{!diff
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 45192b7809..603b7056ad 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -2402,6 +2402,8 @@ class Query(BaseExpression):
self.extra_order_by = ()
if clear_default:
self.default_ordering = False
+ for query in self.combined_queries:
+ query.clear_ordering(force=force,
clear_default=clear_default)
def set_group_by(self, allow_aliases=True):
"""
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37097#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 visit
https://groups.google.com/d/msgid/django-updates/0107019e1dcda644-491d2b30-04d8-4e78-8b26-9161e38fce60-000000%40eu-central-1.amazonses.com.