]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
Add test for Field `exclude` parameter
authorYurii Motov <yurii.motov.monte@gmail.com>
Wed, 28 Jan 2026 09:39:25 +0000 (10:39 +0100)
committerYurii Motov <yurii.motov.monte@gmail.com>
Wed, 28 Jan 2026 09:39:25 +0000 (10:39 +0100)
tests/test_pydantic/test_field.py

index 140b02fd9b1845d4c515df03828f50e41584a7d5..68858cf719903a1689ced2223e0f72a7a8cb90a1 100644 (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