🐛 Fix RuntimeError: dictionary changed size during iteration in sqlmodel_update() (#997)

Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
This commit is contained in:
Bart Schuurmans
2025-12-23 17:23:54 +01:00
committed by GitHub
parent fb331e7ce7
commit 6cec19c8dc
2 changed files with 21 additions and 2 deletions

View File

@@ -1004,9 +1004,8 @@ class SQLModel(BaseModel, metaclass=SQLModelMetaclass, registry=default_registry
else:
value = getattr(obj, key)
setattr(self, key, value)
for remaining_key in use_update:
for remaining_key, value in use_update.items():
if remaining_key in get_model_fields(self):
value = use_update.pop(remaining_key)
setattr(self, remaining_key, value)
else:
raise ValueError(