From: Mike Bayer Date: Thu, 23 Aug 2012 01:02:48 +0000 (-0400) Subject: - [bug] Fixed MySQL rendering for server_default which X-Git-Tag: rel_0_4_0~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91bfdca078e3b36dcaccf3dbcf0d8013587d06d2;p=thirdparty%2Fsqlalchemy%2Falembic.git - [bug] Fixed MySQL rendering for server_default which didn't work if the server_default was a generated SQL expression. Courtesy Moriyoshi Koizumi. --- diff --git a/CHANGES b/CHANGES index 1de83319..d22b4f14 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +0.3.7 +===== +- [bug] Fixed MySQL rendering for server_default which + didn't work if the server_default was a generated + SQL expression. Courtesy Moriyoshi Koizumi. + 0.3.6 ===== - [feature] Added include_symbol option to diff --git a/alembic/__init__.py b/alembic/__init__.py index 38e81077..36db19fe 100644 --- a/alembic/__init__.py +++ b/alembic/__init__.py @@ -1,6 +1,6 @@ from os import path -__version__ = '0.3.6' +__version__ = '0.3.7' package_dir = path.abspath(path.dirname(__file__)) diff --git a/tests/test_mysql.py b/tests/test_mysql.py index a47ef9d5..02f04192 100644 --- a/tests/test_mysql.py +++ b/tests/test_mysql.py @@ -1,7 +1,8 @@ from tests import op_fixture, assert_raises_message from alembic import op, util from sqlalchemy import Integer, Column, ForeignKey, \ - UniqueConstraint, Table, MetaData, String + UniqueConstraint, Table, MetaData, String,\ + func from sqlalchemy.sql import table def test_rename_column(): @@ -18,6 +19,16 @@ def test_rename_column_serv_default(): "ALTER TABLE t1 CHANGE c1 c2 INTEGER NULL DEFAULT 'q'" ) +def test_rename_column_serv_compiled_default(): + context = op_fixture('mysql') + op.alter_column('t1', 'c1', name="c2", existing_type=Integer, + existing_server_default=func.utc_thing(func.current_timestamp())) + # this is not a valid MySQL default but the point is to just + # test SQL expression rendering + context.assert_( + "ALTER TABLE t1 CHANGE c1 c2 INTEGER NULL DEFAULT utc_thing(CURRENT_TIMESTAMP)" + ) + def test_col_nullable(): context = op_fixture('mysql') op.alter_column('t1', 'c1', nullable=False, existing_type=Integer)