File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -572,18 +572,18 @@ def get_config(name: str) -> Any:
572572 if isinstance (original_field , FieldInfo ):
573573 field = original_field
574574 else :
575- annotated_field = next (
576- ann
577- for c in new_cls . __mro__
578- if ( ann := get_annotations ( c . __dict__ ). get ( k )) # type: ignore[arg-type]
579- )
580- annotated_field_meta = getattr (
581- annotated_field , "__metadata__" , (())
582- )
583- field = next (
584- ( f for f in annotated_field_meta if isinstance ( f , FieldInfo )),
585- v ,
586- ) # type: ignore[assignment]
575+ field = v # type: ignore[assignment]
576+ # Update the FieldInfo with the correct class from annotation.
577+ # This is required because pydantic overrides the field with its own
578+ # class and the reference for sqlmodel.FieldInfo is lost.
579+ for c in new_cls . __mro__ :
580+ if annotated := get_annotations ( c . __dict__ ). get ( k ): # type: ignore[arg-type]
581+ for meta in getattr ( annotated , "__metadata__" , ()):
582+ if isinstance ( meta , FieldInfo ):
583+ field = meta
584+ break
585+ break
586+
587587 field .annotation = v .annotation
588588 # Guarantee the field has the correct type
589589 col = get_column_from_field (field )
You can’t perform that action at this time.
0 commit comments