Skip to content
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
66e1bfe
Fix sqlmodel field being overide by pydantic
stickm4n Oct 11, 2025
93e15c1
Add tests for syntax declaration
stickm4n Oct 11, 2025
38dc566
Simplify logic
stickm4n Oct 11, 2025
1b69033
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] Oct 11, 2025
46ce312
Add type ignore comment for field assignment
stickm4n Oct 11, 2025
cf62a18
Remove type ignore comments from execute method signatures
stickm4n Oct 11, 2025
7fd7f0c
Fix inheritance attrib not being properly parsed
stickm4n Oct 11, 2025
28445d1
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] Oct 11, 2025
b867ad7
Fix inheritance when getting annotations
stickm4n Oct 11, 2025
68beb72
Fix type ignore comment for annotation retrieval
stickm4n Oct 11, 2025
45af011
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] Oct 11, 2025
b50566d
Fix col form field for pydantic 1
stickm4n Oct 11, 2025
6fd5534
Fix import
stickm4n Oct 11, 2025
ee8fd7b
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] Oct 11, 2025
eb3cfcc
Fix field annotation retrieval for pydantic integration
stickm4n Oct 20, 2025
7d75b6e
Merge branch 'main' into pydantic-2.12-integration
svlandeg Oct 21, 2025
16c21c1
🐛 Fix composite primary with AfterValidator/Annotated
patrick91 Oct 9, 2025
984e040
Merge branch 'main' into pydantic-2.12-integration
svlandeg Oct 30, 2025
9235285
refactor according to Yurii's suggestion
svlandeg Oct 30, 2025
57f75ef
Merge branch 'pydantic-2.12-integration' of https://github.com/stickM…
svlandeg Oct 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix sqlmodel field being overide by pydantic
  • Loading branch information
stickm4n committed Oct 11, 2025
commit 66e1bfe3d1db2e502416897e32e3fd444d28bc47
9 changes: 8 additions & 1 deletion sqlmodel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,14 @@ def get_config(name: str) -> Any:
# If it was passed by kwargs, ensure it's also set in config
set_config_value(model=new_cls, parameter="table", value=config_table)
for k, v in get_model_fields(new_cls).items():
col = get_column_from_field(v)
original_field = getattr(v, "_original_assignment", Undefined)
annotated_field_meta = new_cls.__annotations__[k].__dict__.get("__metadata__", [])
annotated_field = next((f for f in annotated_field_meta if isinstance(f, FieldInfo)), None)
field = original_field if isinstance(original_field, FieldInfo) else (annotated_field or v)
# Get the original sqlmodel FieldInfo, pydantic >=v2.12 changes the model
field.annotation = v.annotation
# Guarantee the field has the correct type
col = get_column_from_field(field)
setattr(new_cls, k, col)
# Set a config flag to tell FastAPI that this should be read with a field
# in orm_mode instead of preemptively converting it to a dict.
Expand Down