Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
np-kyokyo committed Jul 12, 2024
1 parent 2a60532 commit c6c83e5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/sqlacodegen/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,17 @@ def fix_column_types(self, table: Table) -> None:

def get_adapted_type(self, coltype: Any) -> Any:
compiled_type = coltype.compile(self.bind.engine.dialect)
adapted_type: Any = None
for supercls in coltype.__class__.__mro__:
if not supercls.__name__.startswith("_") and hasattr(
supercls, "__visit_name__"
):
if (
supercls.__visit_name__ == "user_defined"
and adapted_type is not None
):
continue

# Hack to fix adaptation of the Enum class which is broken since
# SQLAlchemy 1.2
kw = {}
Expand Down Expand Up @@ -701,11 +708,11 @@ def get_adapted_type(self, coltype: Any) -> Any:
break

# Stop on the first valid non-uppercase column type class
coltype = new_coltype
adapted_type = new_coltype
if supercls.__name__ != supercls.__name__.upper():
break

return coltype
return adapted_type


class DeclarativeGenerator(TablesGenerator):
Expand Down

0 comments on commit c6c83e5

Please sign in to comment.