FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

✨ Support `pattern` parameter by stickm4n · Pull Request #1231 · fastapi/sqlmodel · GitHub

Repository navigation

✨ Support pattern parameter - #1231

Open
stickm4n wants to merge 24 commits into
fastapi:mainfrom
stickm4n:main
Open

stickm4n wants to merge 24 commits into
fastapi:mainfrom
stickm4n:main

Conversation

stickm4n commented Dec 1, 2024 •
edited by YuriiMotov
Loading

Copy link
Copy Markdown
Contributor

I faced this issue with Pydantic V2 and there is a simple workaround to it by passing the pattern Field parameter as schema extra:

Ex:

class MyClass(SQLModel)
    id: str = Field(unique=True, schema_extra={'pattern': r"^\d{5}$"})

I don't know if this issue was already fixed in another branch, I saw there was a temporary PR already made but closed.

Copy link
Copy Markdown
Contributor Author

@tiangolo @alejsdev or some other maintainer... could you please review this issue?

svlandeg changed the title Add compatibility for Pydantic V2 regex (renamed param from regex to … 💥 Rename regex to param to provide compatibility with Pydantic V2 Feb 20, 2025

Copy link
Copy Markdown
Member

Thanks for the PR! We're going through the backlog of PRs right now, and will get back to you once we've had the time to review this and consider the (breaking) change 🙏

stickm4n commented Feb 22, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

@svlandeg Nice to hear you are taking action on this matter. There is remark, the parameter the was renamed between Pydantic v1 and v2 is regex-> pattern, not as listed in the PR.

The suggestion I made in the PR was to keep both versions compatible when upgrading, but there is an alternative, which is not managing the change between them and just provide the proper type hints.

If you want me to update the PR just let me know, IDK which approach is more adequate for the project.

This comment was marked as resolved.

stickm4n changed the title 💥 Rename regex to param to provide compatibility with Pydantic V2 💥 Rename regex to pattern to provide compatibility with Pydantic V2 Aug 8, 2025

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

github-actions Bot removed the waiting label Aug 28, 2025
stickm4n force-pushed the main branch 2 times, most recently from a5e8961 to 0b9f96f Compare August 30, 2025 11:29

This comment was marked as resolved.

This comment was marked as resolved.

github-actions Bot removed the waiting label Sep 9, 2025

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

YuriiMotov added feature New feature or request and removed breaking labels Sep 10, 2025
YuriiMotov changed the title 💥 Rename regex to pattern to provide compatibility with Pydantic V2 ✨ Support pattern parameter Sep 10, 2025
github-actions Bot removed the conflicts Automatically generated when a PR has a merge conflict label Jan 28, 2026

YuriiMotov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM!

This keep supporting old ways of specifying pattern (regex parameter, and pattern via schema_extra), but emits warnings in these cases. We will remove this support in the future versions.

This comment was marked as resolved.

github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Feb 20, 2026
github-actions Bot removed the conflicts Automatically generated when a PR has a merge conflict label Feb 21, 2026

This comment was marked as resolved.

github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Apr 3, 2026
github-actions Bot removed the conflicts Automatically generated when a PR has a merge conflict label Apr 3, 2026
Comment thread sqlmodel/main.py Outdated
stickm4n requested a review from YuriiMotov April 5, 2026 07:39

stickm4n left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@YuriiMotov I added a blocking comment, please review it and let me know if you will address it (since it was your change to clean the code and prepare the PR) or should I? Anyway I will be around... 🤠

PS: Annotations were updated for re.Pattern support.

Comment thread sqlmodel/main.py

Copy link
Copy Markdown

guys what's the news on this?
mind you the regex parameter is ignored in validation and using it blindly could lead to potential bugs.

YuriiMotov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM!

github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Aug 28, 2026

This comment was marked as resolved.

github-actions Bot removed the conflicts Automatically generated when a PR has a merge conflict label Sep 1, 2026

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL