Skip to content

Conversation

@stickM4N
Copy link

After pydantic update to support Python 3.14, different declaration syntax were affected by the changed.
I check and on pydantic side there is not changes on the resulting FieldInfo structure, at least at first glance.
In the tests I illustrated the 3 possible declaration syntax for annotations defined by pydantic and supported so far by sqlmodel. Two of them do not work any more with pydantic>=2.12!

@stickM4N

This comment has been minimized.

@stickM4N

This comment was marked as resolved.

@stickM4N
Copy link
Author

solves #1602

@YuriiMotov YuriiMotov changed the title Pydantic 2.12 declaration syntax broken 🐛 Fix support for Annotated fields with Pydantic 2.12+ Oct 20, 2025
@YuriiMotov YuriiMotov added the bug Something isn't working label Oct 20, 2025
@stickM4N stickM4N force-pushed the pydantic-2.12-integration branch from 3f6bec5 to eb3cfcc Compare October 20, 2025 20:48
@wguilen
Copy link

wguilen commented Oct 22, 2025

Any idea on when a new release with this fix will be available?

@stickM4N
Copy link
Author

Any idea on when a new release with this fix will be available?

Not really, hopefully soon!
I would still recommend to use pydantic<2.12 if python 3.14 is not required... there have been big changes recently that could have included some malfunctions like this

@wguilen
Copy link

wguilen commented Oct 22, 2025

Any idea on when a new release with this fix will be available?

Not really, hopefully soon! I would still recommend to use pydantic<2.12 if python 3.14 is not required... there have been big changes recently that could have included some malfunctions like this

That's alright, I'll follow your suggestion. Thanks for the quick reply!

@svlandeg svlandeg self-assigned this Oct 30, 2025
@svlandeg svlandeg changed the title 🐛 Fix support for Annotated fields with Pydantic 2.12+ 🐛 Fix support for Annotated fields with Pydantic 2.12+ (alternative 1) Oct 30, 2025
Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

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

Hi @stickM4N, thanks for the PR! I'm going to push some changes to your branch directly, to include also the tests from #1602 and to get the PR in a good state to merge. I'll put it in draft while I work on it.

@stickM4N
Copy link
Author

Hi @stickM4N, thanks for the PR! I'm going to push some changes to your branch directly, to include also the tests from #1602 and to get the PR in a good state to merge. I'll put it in draft while I work on it.

Perfect, feel free to do it!
It will be nice for this to me merged soon.

@svlandeg svlandeg marked this pull request as draft October 30, 2025 20:57
@svlandeg svlandeg marked this pull request as ready for review October 30, 2025 21:33
@svlandeg svlandeg changed the title 🐛 Fix support for Annotated fields with Pydantic 2.12+ (alternative 1) 🐛 Fix support for Annotated fields with Pydantic 2.12+ Oct 30, 2025
Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

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

Thanks for the work on this, @stickM4N!

This now looks good to merge to me. I've added in the tests from #1602 just for good measure, and refactored the code a bit using Yurii's suggestions. I think it's much easier to follow/maintain like this, without the continue & break statements.

Will yet run this by Tiangolo for a final review.
Note that another alternative to this PR is #1607 - if we decide to merge this, we can close the other one.

@svlandeg svlandeg removed their assignment Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLModel fails to create DB constraints when using Annotated types after Pydantic 2.12.0

5 participants