From a046bcadbee2dc0e6c889f82c08b5a21a32359ad Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Thu, 17 Sep 2020 08:26:06 +0200 Subject: Fixed #31916 -- Fixed combined queryset crash when combining with ordered combined querysets. --- django/db/models/sql/compiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 208f0ddf73..2fedef62fc 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -359,7 +359,7 @@ class SQLCompiler: for expr, is_ref in order_by: resolved = expr.resolve_expression(self.query, allow_joins=True, reuse=None) - if self.query.combinator: + if self.query.combinator and self.select: src = resolved.get_source_expressions()[0] expr_src = expr.get_source_expressions()[0] # Relabel order by columns to raw numbers if this is a combined -- cgit v1.3