Skip to content

Commit b2c1f53

Browse files
committed
Add test for Field exclude parameter
1 parent 2863b52 commit b2c1f53

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/test_pydantic/test_field.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,16 @@ class Model(SQLModel):
5454

5555
instance = Model(id=123, foo="bar")
5656
assert "foo=" not in repr(instance)
57+
58+
59+
def test_exclude():
60+
class Model(SQLModel):
61+
id: int
62+
name: str
63+
value: int = Field(exclude=True)
64+
65+
instance = Model(id=1, name="test", value=42)
66+
dict_representation = instance.model_dump()
67+
assert "id" in dict_representation
68+
assert "name" in dict_representation
69+
assert "value" not in dict_representation

0 commit comments

Comments
 (0)