Add test for Field exclude parameter

This commit is contained in:
Yurii Motov
2026-01-28 10:39:25 +01:00
parent 2863b52c92
commit b2c1f53b9b

View File

@@ -54,3 +54,16 @@ def test_repr():
instance = Model(id=123, foo="bar")
assert "foo=" not in repr(instance)
def test_exclude():
class Model(SQLModel):
id: int
name: str
value: int = Field(exclude=True)
instance = Model(id=1, name="test", value=42)
dict_representation = instance.model_dump()
assert "id" in dict_representation
assert "name" in dict_representation
assert "value" not in dict_representation