mirror of
https://github.com/fastapi/sqlmodel.git
synced 2026-03-13 09:29:54 +08:00
Add test for Field exclude parameter
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user