@@ -223,7 +223,7 @@ def test_literal_valid_values(clear_sqlmodel, caplog):
223223 """Test https://github.com/fastapi/sqlmodel/issues/57"""
224224
225225 class Model (SQLModel , table = True ):
226- id : Optional [ int ] = Field (default = None , primary_key = True )
226+ id : int | None = Field (default = None , primary_key = True )
227227 all_str : Literal ["a" , "b" , "c" ]
228228 mixed : Literal ["yes" , "no" , 1 , 0 ]
229229 all_int : Literal [1 , 2 , 3 ]
@@ -270,7 +270,7 @@ def test_literal_constraints_invalid_values(clear_sqlmodel):
270270 """DB should reject values that are not part of the Literal choices."""
271271
272272 class Model (SQLModel , table = True ):
273- id : Optional [ int ] = Field (default = None , primary_key = True )
273+ id : int | None = Field (default = None , primary_key = True )
274274 all_str : Literal ["a" , "b" , "c" ]
275275 mixed : Literal ["yes" , "no" , 1 , 0 ]
276276 all_int : Literal [1 , 2 , 3 ]
@@ -330,8 +330,8 @@ def test_literal_optional_and_union_constraints(clear_sqlmodel):
330330 """Literals inside Optional/Union should also be enforced at the DB level."""
331331
332332 class Model (SQLModel , table = True ):
333- id : Optional [ int ] = Field (default = None , primary_key = True )
334- opt_str : Optional [ Literal ["x" , "y" ]] = None
333+ id : int | None = Field (default = None , primary_key = True )
334+ opt_str : Literal ["x" , "y" ] | None = None
335335 union_int : Union [Literal [10 , 20 ], None ] = None
336336
337337 engine = create_engine ("sqlite://" )
0 commit comments