-
Notifications
You must be signed in to change notification settings - Fork 158
Closed
Description
We're using sqlalchemy-redshift with Alembic, and have found that we are unable to add or change comments on columns. Creating a new column with a comment works fine though.
Let me know if there's any more information I can provide, or if I should open this issue with SQLAlchemy or Alembic.
from alembic import op
op.alter_column(
'some_table',
'some_column',
comment='my column comment',
)
sqlalchemy.exc.CompileError: <class 'alembic.ddl.base.ColumnComment'> construct has no default compilation handler.
click for full traceback
Traceback (most recent call last):
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 88, in _compiler_dispatch
meth = getter(visitor)
AttributeError: 'RedshiftDDLCompiler' object has no attribute 'visit_clause'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/ext/compiler.py", line 423, in _wrap_existing_dispatch
return existing_dispatch(element, compiler, **kw)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 90, in _compiler_dispatch
raise exc.UnsupportedCompilationError(visitor, cls)
sqlalchemy.exc.UnsupportedCompilationError: Compiler <sqlalchemy_redshift.dialect.RedshiftDDLCompiler object at 0x7f2436379a20> can't render element of type <class 'sqlalchemy.sql.elements.ClauseElement'> (Background on this error at: http://sqlalche.me/e/l7de)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/elliott/.virtualenvs/dwp/bin/alembic", line 10, in <module>
sys.exit(main())
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/config.py", line 573, in main
CommandLine(prog=prog).main(argv=argv)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/config.py", line 567, in main
self.run_cmd(cfg, options)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/config.py", line 547, in run_cmd
**dict((k, getattr(options, k, None)) for k in kwarg)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/command.py", line 298, in upgrade
script.run_env()
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/script/base.py", line 489, in run_env
util.load_python_file(self.dir, "env.py")
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/util/pyfiles.py", line 98, in load_python_file
module = load_module_py(module_id, path)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/util/compat.py", line 173, in load_module_py
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "alembic/env.py", line 152, in <module>
run_migrations_online()
File "alembic/env.py", line 146, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/runtime/environment.py", line 846, in run_migrations
self.get_context().run_migrations(**kw)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/runtime/migration.py", line 518, in run_migrations
step.migration_fn(**kw)
File "/home/elliott/dwp/arthur/ltbd/alembic/versions/2020-02-06_60f608383d18_column_comment_test.py", line 24, in upgrade
comment="test comment",
File "<string>", line 8, in alter_column
File "<string>", line 3, in alter_column
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/operations/ops.py", line 1777, in alter_column
return operations.invoke(alt)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/operations/base.py", line 345, in invoke
return fn(self, operation)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/operations/toimpl.py", line 56, in alter_column
**operation.kw
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/ddl/postgresql.py", line 140, in alter_column
**kw
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/ddl/impl.py", line 212, in alter_column
existing_comment=existing_comment,
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/alembic/ddl/impl.py", line 134, in _exec
return conn.execute(construct, *multiparams, **params)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 988, in execute
return meth(self, multiparams, params)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 72, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1043, in _execute_ddl
else None,
File "<string>", line 1, in <lambda>
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 462, in compile
return self._compiler(dialect, bind=bind, **kw)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 29, in _compiler
return dialect.ddl_compiler(dialect, self, **kw)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/compiler.py", line 319, in __init__
self.string = self.process(self.statement, **compile_kwargs)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/sql/compiler.py", line 350, in process
return obj._compiler_dispatch(self, **kwargs)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/ext/compiler.py", line 436, in <lambda>
lambda *arg, **kw: existing(*arg, **kw),
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/ext/compiler.py", line 478, in __call__
return fn(element, compiler, **kw)
File "/home/elliott/.virtualenvs/dwp/lib/python3.6/site-packages/sqlalchemy/ext/compiler.py", line 427, in _wrap_existing_dispatch
"compilation handler." % type(element)
sqlalchemy.exc.CompileError: <class 'alembic.ddl.base.ColumnComment'> construct has no default compilation handler.
Metadata
Metadata
Assignees
Labels
No labels