Refs #32786 -- Made query clear ordering when ordered combined queryset is used in subquery on Oracle.

This commit is contained in:
Mariusz Felisiak 2022-06-24 07:34:24 +02:00
parent 20b6e30858
commit c48b34e26d
2 changed files with 2 additions and 5 deletions

View File

@ -116,11 +116,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
"migrations.test_operations.OperationTests."
"test_alter_field_pk_fk_db_collation",
},
"Oracle raises an error when a subquery contains unnecessary ORDER BY "
"clause (#32786).": {
"queries.test_qs_combinators.QuerySetSetOperationTests."
"test_union_in_with_ordering",
},
}
django_test_expected_failures = {
# A bug in Django/cx_Oracle with respect to string handling (#23843).

View File

@ -1178,6 +1178,8 @@ class Query(BaseExpression):
and not connection.features.ignores_unnecessary_order_by_in_subqueries
):
self.clear_ordering(force=False)
for query in self.combined_queries:
query.clear_ordering(force=False)
sql, params = self.get_compiler(connection=connection).as_sql()
if self.subquery:
sql = "(%s)" % sql