Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💥 Rename regex to param to provide compatibility with Pydantic V2 #1231

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

stickM4N
Copy link

@stickM4N stickM4N commented Dec 1, 2024

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}$"})

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

@stickM4N
Copy link
Author

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

@svlandeg 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
@svlandeg
Copy link
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
Copy link
Author

stickM4N commented Feb 22, 2025

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants