mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[4.1.x] Fixed #33796 -- Fixed ordered combined queryset crash when used in subquery on PostgreSQL and MySQL.
Thanks Shai Berger for the report. Regression in30a0144134. Backport of44ffd8d06ffrom main
This commit is contained in:
@@ -171,6 +171,25 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||
},
|
||||
}
|
||||
)
|
||||
if (
|
||||
self.connection.mysql_is_mariadb and self.connection.mysql_version < (10, 4)
|
||||
) or (
|
||||
not self.connection.mysql_is_mariadb
|
||||
and self.connection.mysql_version < (8,)
|
||||
):
|
||||
skips.update(
|
||||
{
|
||||
"Parenthesized combined queries are not supported on MySQL < 8 and "
|
||||
"MariaDB < 10.4": {
|
||||
"queries.test_qs_combinators.QuerySetSetOperationTests."
|
||||
"test_union_in_subquery",
|
||||
"queries.test_qs_combinators.QuerySetSetOperationTests."
|
||||
"test_union_in_subquery_related_outerref",
|
||||
"queries.test_qs_combinators.QuerySetSetOperationTests."
|
||||
"test_union_in_with_ordering",
|
||||
}
|
||||
}
|
||||
)
|
||||
if not self.supports_explain_analyze:
|
||||
skips.update(
|
||||
{
|
||||
|
||||
@@ -109,6 +109,11 @@ 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).
|
||||
|
||||
@@ -548,6 +548,11 @@ class SQLCompiler:
|
||||
or not features.supports_slicing_ordering_in_compound
|
||||
):
|
||||
part_sql = "({})".format(part_sql)
|
||||
elif (
|
||||
self.query.subquery
|
||||
and features.supports_slicing_ordering_in_compound
|
||||
):
|
||||
part_sql = "({})".format(part_sql)
|
||||
parts += ((part_sql, part_args),)
|
||||
except EmptyResultSet:
|
||||
# Omit the empty queryset with UNION and with DIFFERENCE if the
|
||||
|
||||
Reference in New Issue
Block a user