From 89b8c343ed6247a562e0bcd53ef3fc180d0d4e46 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 17 Feb 2020 15:21:59 -0500 Subject: Pass DDLCompiler IdentifierPreparer to visit_ENUM Fixed issue where the "schema_translate_map" feature would not work with a PostgreSQL native enumeration type (i.e. :class:`.Enum`, :class:`.postgresql.ENUM`) in that while the "CREATE TYPE" statement would be emitted with the correct schema, the schema would not be rendered in the CREATE TABLE statement at the point at which the enumeration was referenced. Fixes: #5158 Change-Id: I41529785de2e736c70a142c2ae5705060bfed73e --- lib/sqlalchemy/dialects/postgresql/base.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/dialects') diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index ceefc20b0..45911d4c0 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1887,7 +1887,9 @@ class PGDDLCompiler(compiler.DDLCompiler): colspec += " SERIAL" else: colspec += " " + self.dialect.type_compiler.process( - column.type, type_expression=column + column.type, + type_expression=column, + identifier_preparer=self.preparer, ) default = self.get_column_default_string(column) if default is not None: @@ -2149,8 +2151,11 @@ class PGTypeCompiler(compiler.GenericTypeCompiler): else: return self.visit_ENUM(type_, **kw) - def visit_ENUM(self, type_, **kw): - return self.dialect.identifier_preparer.format_type(type_) + def visit_ENUM(self, type_, identifier_preparer=None, **kw): + if identifier_preparer is None: + identifier_preparer = self.dialect.identifier_preparer + + return identifier_preparer.format_type(type_) def visit_TIMESTAMP(self, type_, **kw): return "TIMESTAMP%s %s" % ( -- cgit v1.2.1