From c4e3d919368d158f839a6ea6278a28007fb7f5dc Mon Sep 17 00:00:00 2001 From: Cody Fincher <204685+cofin@users.noreply.github.com> Date: Sat, 17 Feb 2024 11:55:29 -0800 Subject: [PATCH] fix: prefer `sqlalchemy.type.impl` if it exists (#502) --- polyfactory/factories/sqlalchemy_factory.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/polyfactory/factories/sqlalchemy_factory.py b/polyfactory/factories/sqlalchemy_factory.py index f34d3af6..ad8873f6 100644 --- a/polyfactory/factories/sqlalchemy_factory.py +++ b/polyfactory/factories/sqlalchemy_factory.py @@ -126,7 +126,11 @@ def get_type_from_column(cls, column: Column) -> type: elif issubclass(column_type, types.ARRAY): annotation = List[column.type.item_type.python_type] # type: ignore[assignment,name-defined] else: - annotation = column.type.python_type + annotation = ( + column.type.impl.python_type # pyright: ignore[reportGeneralTypeIssues] + if hasattr(column.type, "impl") + else column.type.python_type + ) if column.nullable: annotation = Union[annotation, None] # type: ignore[assignment]