diff --git a/tests/unit/sqlalchemy/test_compiler.py b/tests/unit/sqlalchemy/test_compiler.py index 779d0cd9..00bd686c 100644 --- a/tests/unit/sqlalchemy/test_compiler.py +++ b/tests/unit/sqlalchemy/test_compiler.py @@ -27,13 +27,13 @@ table = Table( 'table', metadata, - Column('id', Integer, primary_key=True), + Column('id', Integer), Column('name', String), ) table_with_catalog = Table( 'table', metadata, - Column('id', Integer, primary_key=True), + Column('id', Integer), schema='default', trino_catalog='other' ) @@ -86,7 +86,6 @@ def test_catalogs_create_table(dialect): assert str(query) == \ '\n'\ 'CREATE TABLE "other".default."table" (\n'\ - '\tid INTEGER NOT NULL, \n'\ - '\tPRIMARY KEY (id)\n'\ + '\tid INTEGER\n'\ ')\n'\ '\n' diff --git a/trino/sqlalchemy/compiler.py b/trino/sqlalchemy/compiler.py index f9f4e8fd..a085fbf3 100644 --- a/trino/sqlalchemy/compiler.py +++ b/trino/sqlalchemy/compiler.py @@ -17,6 +17,7 @@ Subquery, ) except ImportError: + # For SQLAlchemy versions < 1.4, the CTE and Subquery classes did not explicitly exist from sqlalchemy.sql.expression import Alias CTE = type(None) Subquery = type(None) @@ -129,12 +130,12 @@ def add_catalog(sql, table): if ( 'trino' not in table.dialect_options - or 'catalog' not in table.dialect_options['trino']._non_defaults + or 'catalog' not in table.dialect_options['trino'] ): return sql - catalog = table.dialect_options['trino']._non_defaults['catalog'] - sql = '"{catalog}".{sql}'.format(catalog=catalog, sql=sql) + catalog = table.dialect_options['trino']['catalog'] + sql = f'"{catalog}".{sql}' return sql