File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -91,13 +91,14 @@ class Hero(SQLModel, table=True):
9191
9292 with Session (engine ) as session :
9393 hero = session .get (Hero , 1 )
94- assert not session .dirty
95- assert not session .new
94+ assert session ._is_clean ()
9695
97- Hero .validate (hero )
96+ new_hero = Hero .validate (hero )
9897
99- assert not session .dirty
100- assert not session .new
98+ assert session ._is_clean ()
99+ # The new hero is a different instance, but the team is the same
100+ assert id (new_hero ) != id (hero )
101+ assert id (new_hero .team ) == id (hero .team )
101102
102103
103104@needs_pydanticv2
@@ -127,6 +128,9 @@ class Hero(SQLModel, table=True):
127128 hero = session .get (Hero , 1 )
128129 assert session ._is_clean ()
129130
130- Hero .model_validate (hero )
131+ new_hero = Hero .model_validate (hero )
131132
132133 assert session ._is_clean ()
134+ # The new hero is a different instance, but the team is the same
135+ assert id (new_hero ) != id (hero )
136+ assert id (new_hero .team ) == id (hero .team )
You can’t perform that action at this time.
0 commit comments