Raise an exception when using a Pydantic field type with no matching SQLAlchemy type (#18)

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
Jakob Jul Elben
2022-08-27 22:13:32 +02:00
committed by GitHub
parent db29f53295
commit dc4dc42ec5
2 changed files with 22 additions and 0 deletions

View File

@ -415,6 +415,7 @@ def get_sqlachemy_type(field: ModelField) -> Any:
return AutoString
if issubclass(field.type_, uuid.UUID):
return GUID
raise ValueError(f"The field {field.name} has no matching SQLAlchemy type")
def get_column_from_field(field: ModelField) -> Column: # type: ignore