From a142edcc4981bb27f4356acad0c7fdfb2d5f9849 Mon Sep 17 00:00:00 2001
From: Simon Charette <charette.s@gmail.com>
Date: Mon, 4 Jul 2022 16:32:16 +0100
Subject: [PATCH] Avoided unnecessary call to .get_source_expressions().

The SQLCompiler._order_by_pairs() generator method yields instances of
OrderBy and not Expression.
---
 django/db/models/sql/compiler.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 4f2783a635..4668a820fb 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -436,8 +436,8 @@ class SQLCompiler:
         for expr, is_ref in self._order_by_pairs():
             resolved = expr.resolve_expression(self.query, allow_joins=True, reuse=None)
             if self.query.combinator and self.select:
-                src = resolved.get_source_expressions()[0]
-                expr_src = expr.get_source_expressions()[0]
+                src = resolved.expression
+                expr_src = expr.expression
                 # Relabel order by columns to raw numbers if this is a combined
                 # query; necessary since the columns can't be referenced by the
                 # fully qualified name and the simple column names may collide.