summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2024-07-16 14:00:30 -0400
committerGitHub <noreply@github.com>2024-07-16 15:00:30 -0300
commit252eaca87fc0459dae71c771ca94bf2772127e5a (patch)
tree97cc1a19d116630e7bf7b1bc8a5993132995263f /django/db/models/sql
parent082fe2b5a83571dec4aa97580af0fe8cf2a5214e (diff)
Doc'd purpose of tuple() in SQLCompiler.get_from_clause().
It was added in 01d440fa1e6b5c62acfa8b3fde43dfa1505f93c6 to prevent "RuntimeError: OrderedDict mutated during iteration". That particular issue was fixed in d660cee5bc68b597503c2a16f3d9928d52f93fb4 but the issue could remain in Join.as_sql() subclasses. Co-authored-by: Simon Charette <charette.s@gmail.com>
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/compiler.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index fe22163961..98feb42716 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1134,6 +1134,9 @@ class SQLCompiler:
"""
result = []
params = []
+ # Copy alias_map to a tuple in case Join.as_sql() subclasses (objects
+ # in alias_map) alter compiler.query.alias_map. That would otherwise
+ # raise "RuntimeError: dictionary changed size during iteration".
for alias, from_clause in tuple(self.query.alias_map.items()):
if not self.query.alias_refcount[alias]:
continue