| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
I can reproduce this issue as well. As a workaround I was able to use schema_extra like this: 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 Field should use pattern as well and support regex as an alias? |
|
I was unaware of the schema_extra argument. Thank you! That helps a lot! |
|
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 main.py file with these attributes and the appropriate annotations. |
|
Linking the PR :-) |
|
As of this date, the problem of regexp still exists, as it should instead be named pattern. |
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
{{title}}
Uh oh!
There was an error while loading. Please reload this page.
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 the Field class to create a regular expression validation, but that doesn't work anymore. According to the docs of Pydantic, this should be pattern, 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