Skip to content

Commit 8f10485

Browse files
committed
Support upcoming changes in Pydantic version 2.10.
Without this fix, any SQLModel-based model with `table=True` and a `Field` that sets `default_factory=...` will brake with the following error message: `ValueError: 'validated_data' must be provided if 'call_default_factory' is True.`
1 parent e86b5fc commit 8f10485

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sqlmodel/_compat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ def sqlmodel_table_construct(
252252
elif name in values:
253253
fields_values[name] = values.pop(name)
254254
elif not field.is_required():
255-
defaults[name] = field.get_default(call_default_factory=True)
255+
defaults[name] = field.get_default(call_default_factory=True,
256+
validated_data=fields_values)
256257
if _fields_set is None:
257258
_fields_set = set(fields_values.keys())
258259
fields_values.update(defaults)

0 commit comments

Comments
 (0)