From 082fe2b5a83571dec4aa97580af0fe8cf2a5214e Mon Sep 17 00:00:00 2001 From: nessita <124304+nessita@users.noreply.github.com> Date: Mon, 15 Jul 2024 16:20:24 -0300 Subject: [PATCH] Removed leftover KeyError handling after Query.tables attribute cleanup. Follow up from f7f5edd50d03e8482f8a6da5fb5202b895d68cd6. --- django/db/models/sql/compiler.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index f3aed06d81..fe22163961 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -1134,15 +1134,9 @@ class SQLCompiler: """ result = [] params = [] - for alias in tuple(self.query.alias_map): + for alias, from_clause in tuple(self.query.alias_map.items()): if not self.query.alias_refcount[alias]: continue - try: - from_clause = self.query.alias_map[alias] - except KeyError: - # Extra tables can end up in self.tables, but not in the - # alias_map if they aren't in a join. That's OK. We skip them. - continue clause_sql, clause_params = self.compile(from_clause) result.append(clause_sql) params.extend(clause_params)