1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #34267 -- Fixed sliced QuerySet.union() crash.

Regression in 3d734c09ff.

Thanks Raphaël Stefanini for the report.
This commit is contained in:
Francesco Panico
2023-01-18 22:42:53 +00:00
committed by Mariusz Felisiak
parent 79c298c9ce
commit cc8aa6bf9c
2 changed files with 12 additions and 7 deletions

View File

@@ -532,15 +532,12 @@ class SQLCompiler:
"ORDER BY not allowed in subqueries of compound statements."
)
elif self.query.is_sliced and combinator == "union":
limit = (self.query.low_mark, self.query.high_mark)
for compiler in compilers:
# A sliced union cannot have its parts elided as some of them
# might be sliced as well and in the event where only a single
# part produces a non-empty resultset it might be impossible to
# generate valid SQL.
compiler.elide_empty = False
if not compiler.query.is_sliced:
compiler.query.set_limits(*limit)
parts = ()
for compiler in compilers:
try: