sqlmodel icon indicating copy to clipboard operation
sqlmodel copied to clipboard

Fix regex argument in Field class (pydantic2)

Open n0061q opened this issue 2 years ago • 0 comments

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.

n0061q avatar Jan 08 '24 13:01 n0061q