🐛 Fix support for types with Optional[Annoated[x, f()]], e.g. id: Optional[pydantic.UUID4] (#1093)

This commit is contained in:
Sebastián Ramírez
2024-08-31 11:38:19 +02:00
committed by GitHub
parent 4eaf8b9efb
commit a14ab0bd3c
3 changed files with 43 additions and 11 deletions

View File

@@ -71,7 +71,7 @@ from ._compat import ( # type: ignore[attr-defined]
get_field_metadata,
get_model_fields,
get_relationship_to,
get_type_from_field,
get_sa_type_from_field,
init_pydantic_private_attrs,
is_field_noneable,
is_table_model_class,
@@ -649,7 +649,7 @@ def get_sqlalchemy_type(field: Any) -> Any:
if sa_type is not Undefined:
return sa_type
type_ = get_type_from_field(field)
type_ = get_sa_type_from_field(field)
metadata = get_field_metadata(field)
# Check enums first as an enum can also be a str, needed by Pydantic/FastAPI