Skip to content

Commit b50566d

Browse files
committed
Fix col form field for pydantic 1
1 parent 45af011 commit b50566d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sqlmodel/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,11 @@ def get_config(name: str) -> Any:
562562
# If it was passed by kwargs, ensure it's also set in config
563563
set_config_value(model=new_cls, parameter="table", value=config_table)
564564
for k, v in get_model_fields(new_cls).items():
565+
if not IS_PYDANTIC_V2:
566+
col = get_column_from_field(v)
567+
setattr(new_cls, k, col)
568+
continue
569+
565570
original_field = getattr(v, "_original_assignment", Undefined)
566571
# Get the original sqlmodel FieldInfo, pydantic >=v2.12 changes the model
567572
if isinstance(original_field, FieldInfo):
@@ -576,7 +581,8 @@ def get_config(name: str) -> Any:
576581
annotated_field, "__metadata__", (())
577582
)
578583
field = next(
579-
(f for f in annotated_field_meta if isinstance(f, FieldInfo)), v
584+
(f for f in annotated_field_meta if isinstance(f, FieldInfo)),
585+
v,
580586
) # type: ignore[assignment]
581587
field.annotation = v.annotation
582588
# Guarantee the field has the correct type

0 commit comments

Comments
 (0)