Skip to content

Commit 7fd7f0c

Browse files
committed
Fix inheritance attrib not being properly parsed
1 parent cf62a18 commit 7fd7f0c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

sqlmodel/main.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,13 @@ def get_config(name: str) -> Any:
567567
if isinstance(original_field, FieldInfo):
568568
field = original_field
569569
else:
570-
annotated_field_meta = new_cls.__annotations__[k].__dict__.get(
571-
"__metadata__", []
572-
)
570+
annotated_field = get_annotations(new_cls.__dict__).get(k, {})
571+
annotated_field_meta = getattr(annotated_field,"__metadata__", (()))
573572
field = next(
574573
(f for f in annotated_field_meta if isinstance(f, FieldInfo)), v
575574
) # type: ignore[assignment]
576-
field.annotation = v.annotation
577-
# Guarantee the field has the correct type
575+
field.annotation = v.annotation
576+
# Guarantee the field has the correct type
578577
col = get_column_from_field(field)
579578
setattr(new_cls, k, col)
580579
# Set a config flag to tell FastAPI that this should be read with a field

0 commit comments

Comments
 (0)