From c48b34e26d0fd2f445d54d191bfe32d58dfb8e7b Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Fri, 24 Jun 2022 07:34:24 +0200 Subject: [PATCH] Refs #32786 -- Made query clear ordering when ordered combined queryset is used in subquery on Oracle. --- django/db/backends/oracle/features.py | 5 ----- django/db/models/sql/query.py | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/django/db/backends/oracle/features.py b/django/db/backends/oracle/features.py index d5b87ac682..289f786f5e 100644 --- a/django/db/backends/oracle/features.py +++ b/django/db/backends/oracle/features.py @@ -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). diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index f5852542b3..33cc636b22 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -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