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

🐛 Fix composite primary with AfterValidator/Annotated by patrick91 · Pull Request #1602 · fastapi/sqlmodel · GitHub

Repository navigation

🐛 Fix composite primary with AfterValidator/Annotated - #1602

Closed
patrick91 wants to merge 2 commits into
fastapi:mainfrom
patrick91-archive:10-09-_fix_composite_primary_with_aftervalidator_annotated
Closed

patrick91 wants to merge 2 commits into
fastapi:mainfrom
patrick91-archive:10-09-_fix_composite_primary_with_aftervalidator_annotated

Conversation

patrick91 commented Oct 9, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor

The title is currently a lie :D but there's a test for what's broken, and I think it's because the FieldInfo we get in get_column_from_field is the Pydantic one and not the SQLModel one

EDIT: I guess this is not just about primary keys, but it's about any custom attribute used in SQLModel's Field :)

patrick91 force-pushed the 10-09-_fix_composite_primary_with_aftervalidator_annotated branch from 9b502f9 to 25d3e9c Compare October 9, 2025 22:29
patrick91 added the bug Something isn't working label Oct 9, 2025

stickm4n commented Oct 11, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor

I have also being working on solving this and will make a PR solving the issue with the associated tests. I will link it here when its done.
It might be a bug on pydantic side like they had in v2.0.0 and corrected in v2.0.1
For now i suggest to fix the version pydantic~=2.11.10 that works just fine since it have not updated pydantic-core to support python3.14.

vimota commented Oct 15, 2025

Copy link
Copy Markdown
Contributor

Inspired by your test - added a fix here: https://github.com/fastapi/sqlmodel/pull/1607/files

Copy link
Copy Markdown
Contributor Author

@vimota hi Victor! thanks for that, I think it's probably best to wait for @tiangolo to check how to fix this ;)

vimota commented Oct 15, 2025

Copy link
Copy Markdown
Contributor

@vimota hi Victor! thanks for that, I think it's probably best to wait for @tiangolo to check how to fix this ;)

Sounds good - didn't realize he was on it!

For what it's worth, I do think this is exactly what the Pydantic metadata field is for.

stickm4n commented Oct 16, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor

@patrick91 @vimota
Check the PR me and @YuriiMotov linked to this issue.
The problem is not due to resolution of metadata but Pydantic re-associating the values if FieldInfo.
To the the get column method is being passed as a parameter the value of a pydantic.FieldInfo and not a sqlmodel.FieldInfo.

Copy link
Copy Markdown
Member

Closing this one in favor of #1603 and #1607, which both now contain the tests of this PR - we'll just have to pick one of the two to merge.

svlandeg closed this Oct 30, 2025
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

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL