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 --- test/dialect/postgresql/test_compiler.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/dialect/postgresql/test_compiler.py') diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 4c4c43281..aabbc3ac3 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -237,6 +237,22 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): schema_translate_map=schema_translate_map, ) + def test_create_table_with_schema_type_schema_translate(self): + e1 = Enum("x", "y", "z", name="somename") + e2 = Enum("x", "y", "z", name="somename", schema="someschema") + schema_translate_map = {None: "foo", "someschema": "bar"} + + table = Table( + "some_table", MetaData(), Column("q", e1), Column("p", e2) + ) + from sqlalchemy.schema import CreateTable + + self.assert_compile( + CreateTable(table), + "CREATE TABLE foo.some_table (q foo.somename, p bar.somename)", + schema_translate_map=schema_translate_map, + ) + def test_create_table_with_tablespace(self): m = MetaData() tbl = Table( -- cgit v1.2.1