File tree 1 file changed +10
-6
lines changed
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):
91
91
92
92
with Session (engine ) as session :
93
93
hero = session .get (Hero , 1 )
94
- assert not session .dirty
95
- assert not session .new
94
+ assert session ._is_clean ()
96
95
97
- Hero .validate (hero )
96
+ new_hero = Hero .validate (hero )
98
97
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 )
101
102
102
103
103
104
@needs_pydanticv2
@@ -127,6 +128,9 @@ class Hero(SQLModel, table=True):
127
128
hero = session .get (Hero , 1 )
128
129
assert session ._is_clean ()
129
130
130
- Hero .model_validate (hero )
131
+ new_hero = Hero .model_validate (hero )
131
132
132
133
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