Skip to content

Commit c4e3d91

Browse files
authored
fix: prefer sqlalchemy.type.impl if it exists (#502)
1 parent 1ae2d52 commit c4e3d91

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

polyfactory/factories/sqlalchemy_factory.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ def get_type_from_column(cls, column: Column) -> type:
126126
elif issubclass(column_type, types.ARRAY):
127127
annotation = List[column.type.item_type.python_type] # type: ignore[assignment,name-defined]
128128
else:
129-
annotation = column.type.python_type
129+
annotation = (
130+
column.type.impl.python_type # pyright: ignore[reportGeneralTypeIssues]
131+
if hasattr(column.type, "impl")
132+
else column.type.python_type
133+
)
130134

131135
if column.nullable:
132136
annotation = Union[annotation, None] # type: ignore[assignment]

0 commit comments

Comments
 (0)