Skip to content

Commit c8a44e8

Browse files
committed
fix(compat): forward by_alias and by_name parameters in model_validate and sqlmodel_validate
1 parent 8f44815 commit c8a44e8

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

sqlmodel/_compat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ def sqlmodel_validate(
281281
from_attributes: bool | None = None,
282282
context: dict[str, Any] | None = None,
283283
update: dict[str, Any] | None = None,
284+
by_alias: bool | None = None,
285+
by_name: bool | None = None,
284286
) -> _TSQLModel:
285287
if not is_table_model_class(cls):
286288
new_obj: _TSQLModel = cls.__new__(cls)
@@ -303,6 +305,8 @@ def sqlmodel_validate(
303305
strict=strict,
304306
from_attributes=from_attributes,
305307
context=context,
308+
by_alias=by_alias,
309+
by_name=by_name,
306310
self_instance=new_obj,
307311
)
308312
# Capture fields set to restore it later

sqlmodel/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,8 @@ def model_validate( # ty: ignore[invalid-method-override]
877877
from_attributes: bool | None = None,
878878
context: builtins.dict[str, Any] | None = None,
879879
update: builtins.dict[str, Any] | None = None,
880+
by_alias: bool | None = None,
881+
by_name: bool | None = None,
880882
) -> _TSQLModel:
881883
return sqlmodel_validate(
882884
cls=cls,
@@ -885,6 +887,8 @@ def model_validate( # ty: ignore[invalid-method-override]
885887
from_attributes=from_attributes,
886888
context=context,
887889
update=update,
890+
by_alias=by_alias,
891+
by_name=by_name,
888892
)
889893

890894
def model_dump(

0 commit comments

Comments
 (0)