sqlmodel
sqlmodel copied to clipboard
Fix regex argument in Field class (pydantic2)
Reported here #735
Version 0.0.14 added support for pydantic v2 (while keeping support for v1).
In this particular case regex kwarg to Field class is getting silently ignored by pydantic (it is passed through Field > FieldInfo > PydanticFieldInfo) and has no effect.
Here is the most obvious fix which adds pattern=regex to FieldInfo init. This makes sure that pydantic v2 gets proper argument.
I don't know what is the strategy here about pydantic v1 and v2 and argument names in SQLModel. I can adjust PR if needed.