We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bacd6d9 commit 0ed7c7cCopy full SHA for 0ed7c7c
tests/test_update.py
@@ -0,0 +1,23 @@
1
+from sqlmodel import Field, SQLModel, create_engine
2
+
3
4
+def test_sqlmodel_update():
5
+ class Organization(SQLModel, table=True):
6
+ id: int = Field(default=None, primary_key=True)
7
+ name: str
8
+ headquarters: str
9
10
+ class OrganizationUpdate(SQLModel):
11
12
13
+ engine = create_engine("sqlite:///", echo=True)
14
+ SQLModel.metadata.create_all(engine)
15
16
+ org = Organization(name="Example Org", city="New York", headquarters="NYC HQ")
17
+ org_in = OrganizationUpdate(name="Updated org")
18
+ org.sqlmodel_update(
19
+ org_in,
20
+ update={
21
+ "headquarters": "-", # This field is in Organization, but not in OrganizationUpdate
22
+ },
23
+ )
0 commit comments