File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -400,6 +400,12 @@ def Field(
400400 DeprecationWarning ,
401401 stacklevel = 2 ,
402402 )
403+ if "pattern" in current_schema_extra :
404+ warnings .warn (
405+ "Pass `pattern` parameter directly to Field instead of passing it via `schema_extra`" ,
406+ DeprecationWarning ,
407+ stacklevel = 2 ,
408+ )
403409
404410 # Extract possible alias settings from schema_extra so we can control precedence
405411 schema_validation_alias = current_schema_extra .pop ("validation_alias" , None )
Original file line number Diff line number Diff line change @@ -79,8 +79,13 @@ class DateModel(SQLModel):
7979
8080
8181def test_field_pattern_via_schema_extra ():
82- class DateModel (SQLModel ):
83- date_1 : str = Field (schema_extra = {"pattern" : r"^\d{2}-\d{2}-\d{4}$" })
82+ with pytest .warns (
83+ DeprecationWarning ,
84+ match = "Pass `pattern` parameter directly to Field instead of passing it via `schema_extra`" ,
85+ ):
86+
87+ class DateModel (SQLModel ):
88+ date_1 : str = Field (schema_extra = {"pattern" : r"^\d{2}-\d{2}-\d{4}$" })
8489
8590 with pytest .raises (ValidationError ):
8691 DateModel (date_1 = "incorrect" )
You can’t perform that action at this time.
0 commit comments