From: Mike Bayer Date: Sat, 24 Aug 2019 02:23:00 +0000 (-0400) Subject: Include existing_comment in MySQLChangeColumn X-Git-Tag: rel_1_1_0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=802e62fa40b062fc344b1fbadc151e801f91836c;p=thirdparty%2Fsqlalchemy%2Falembic.git Include existing_comment in MySQLChangeColumn Fixed issue where emitting a change of column name for MySQL did not preserve the column comment, even if it were specified as existing_comment. Change-Id: I93a63e5b7c4b629e42088242a9be345de94aa6ea Fixes: #594 --- diff --git a/alembic/ddl/mysql.py b/alembic/ddl/mysql.py index 17ae2de7..e9195996 100644 --- a/alembic/ddl/mysql.py +++ b/alembic/ddl/mysql.py @@ -64,6 +64,9 @@ class MySQLImpl(DefaultImpl): autoincrement=autoincrement if autoincrement is not None else existing_autoincrement, + comment=comment + if comment is not False + else existing_comment, ) ) elif ( diff --git a/docs/build/unreleased/594.rst b/docs/build/unreleased/594.rst new file mode 100644 index 00000000..e68dadc8 --- /dev/null +++ b/docs/build/unreleased/594.rst @@ -0,0 +1,7 @@ +.. change:: + :tags: bug, mysql + :tickets: 594 + + Fixed issue where emitting a change of column name for MySQL did not + preserve the column comment, even if it were specified as existing_comment. + diff --git a/tests/test_mysql.py b/tests/test_mysql.py index fa857b57..ed4b173b 100644 --- a/tests/test_mysql.py +++ b/tests/test_mysql.py @@ -309,6 +309,23 @@ class MySQLOpTest(TestBase): "COMMENT 'existing column comment'" ) + @config.requirements.comments_api + def test_rename_column_existing_comment(self): + context = op_fixture("mysql") + op.alter_column( + "t1", + "c1", + new_column_name="newc1", + existing_nullable=False, + existing_comment="existing column comment", + existing_type=Integer, + ) + + context.assert_( + "ALTER TABLE t1 CHANGE c1 newc1 INTEGER NOT NULL " + "COMMENT 'existing column comment'" + ) + @config.requirements.comments_api def test_alter_column_new_comment_replaces_existing(self): context = op_fixture("mysql")