From: Mike Bayer Date: Sat, 22 Mar 2014 20:21:00 +0000 (-0400) Subject: - add an additional fix to the MySQL fixes for re: #103. X-Git-Tag: rel_0_6_4~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2978071990407cf6593042beda619972c62ea87;p=thirdparty%2Fsqlalchemy%2Falembic.git - add an additional fix to the MySQL fixes for re: #103. --- diff --git a/alembic/ddl/mysql.py b/alembic/ddl/mysql.py index 3d954f6c..088ba59b 100644 --- a/alembic/ddl/mysql.py +++ b/alembic/ddl/mysql.py @@ -177,7 +177,7 @@ def _mysql_colspec(compiler, nullable, server_default, type_, ) if autoincrement: spec += " AUTO_INCREMENT" - if server_default != False: + if server_default is not False and server_default is not None: spec += " DEFAULT %s" % _render_value(compiler, server_default) return spec diff --git a/tests/test_mysql.py b/tests/test_mysql.py index f598d997..16b171c4 100644 --- a/tests/test_mysql.py +++ b/tests/test_mysql.py @@ -90,6 +90,8 @@ class MySQLOpTest(TestCase): 'ALTER TABLE t ALTER COLUMN c DROP DEFAULT' ) + + def test_alter_column_modify_default(self): context = op_fixture('mysql') # notice we dont need the existing type on this one... @@ -127,6 +129,13 @@ class MySQLOpTest(TestCase): "ALTER TABLE t1 MODIFY c1 INTEGER NOT NULL DEFAULT 'q'" ) + def test_alter_column_multi_alter_w_drop_default(self): + context = op_fixture('mysql') + op.alter_column('t1', 'c1', nullable=False, server_default=None, type_=Integer) + context.assert_( + "ALTER TABLE t1 MODIFY c1 INTEGER NOT NULL" + ) + def test_col_alter_type_required(self): op_fixture('mysql') assert_raises_message(