diff --git a/src/sqlacodegen/generators.py b/src/sqlacodegen/generators.py index 21eadb63..c662777b 100644 --- a/src/sqlacodegen/generators.py +++ b/src/sqlacodegen/generators.py @@ -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 = {} @@ -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):