diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-06-24 07:29:58 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-06-27 06:22:37 +0200 |
| commit | d38cd2677e4d8303e70e3bc1119deda7371b369a (patch) | |
| tree | 02ff18794ecd1ebe936658f26d7c682af1944d04 /django/db/models/sql | |
| parent | 2026314b20b78445cbec2eb2de9ff082a5193d7b (diff) | |
[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 in 30a01441347d5a2146af2944b29778fa0834d4be.
Backport of 44ffd8d06fabc07d8333f31439e8dd39ea87329b from main
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/compiler.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 9c7bd8ea1a..461e1ae156 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -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 |
