Coverage for tests / test_update.py: 100%
11 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-01-06 21:09 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-01-06 21:09 +0000
1from sqlmodel import Field, SQLModel 1jklmnopqr
4def test_sqlmodel_update(): 1jklmnopqr
5 class Organization(SQLModel, table=True): 1abcdefghi
6 id: int = Field(default=None, primary_key=True) 1abcdefghi
7 name: str 1abcdefghi
8 headquarters: str 1abcdefghi
10 class OrganizationUpdate(SQLModel): 1abcdefghi
11 name: str 1abcdefghi
13 org = Organization(name="Example Org", city="New York", headquarters="NYC HQ") 1abcdefghi
14 org_in = OrganizationUpdate(name="Updated org") 1abcdefghi
15 org.sqlmodel_update( 1abcdefghi
16 org_in,
17 update={
18 "headquarters": "-", # This field is in Organization, but not in OrganizationUpdate
19 },
20 )