0.0.14
- regex
keyword on Field
object not working (should be pattern
in Pydantic v2)
#735
Replies: 3 comments
-
I can reproduce this issue as well. As a workaround I was able to use class User(SQLModel):
fullname: str = Field(max_length=128, schema_extra={'pattern': r'^[A-Za-z0-9\- ]+$'}) although I'm not sure if this is completely equivalent. If the current version of sqlmodel is targeting both pydantic 1 and pydantic 2, perhaps SQLModel's |
Beta Was this translation helpful? Give feedback.
-
I was unaware of the |
Beta Was this translation helpful? Give feedback.
-
It seems that the SQLModel Field class are not fully compatible with Pydantic v2 Field class.
This is not a lot of work to make the modification in the code as it's just necessary to update the Field class in the |
Beta Was this translation helpful? Give feedback.
-
First Check
Commit to Help
Example Code
Description
I'm migrating from SQLModel 0.0.8 to SQLModel 0.0.14 using Pydantic 2.5.2. In SQLModel 0.0.8 I could use the
regex
keyword from theField
class to create a regular expression validation, but that doesn't work anymore. According to the docs of Pydantic, this should bepattern
, but the Field object of SQLModel doesn't support that named argument.Operating System
Linux
Operating System Details
Pydantic version 2.5.2 (Core = 2.14.5)
SQLModel Version
0.0.14
Python Version
3.10.13
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions