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