Doc'd purpose of tuple() in SQLCompiler.get_from_clause().

It was added in 01d440fa1e to
prevent "RuntimeError: OrderedDict mutated during iteration".
That particular issue was fixed in d660cee5bc
but the issue could remain in Join.as_sql() subclasses.

Co-authored-by: Simon Charette <charette.s@gmail.com>
This commit is contained in:
Tim Graham 2024-07-16 14:00:30 -04:00 committed by GitHub
parent 082fe2b5a8
commit 252eaca87f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -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