From: Mike Bayer Date: Sun, 22 Nov 2015 20:25:00 +0000 (-0500) Subject: - Fixed bug where the ``server_default`` parameter of ``alter_column()`` X-Git-Tag: rel_0_8_4~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3105ed6a45787e74b2954e0f1daf4ba415c8cda6;p=thirdparty%2Fsqlalchemy%2Falembic.git - Fixed bug where the ``server_default`` parameter of ``alter_column()`` would not function correctly in batch mode. fixes #338 --- diff --git a/alembic/operations/batch.py b/alembic/operations/batch.py index 769cd92e..369d08dd 100644 --- a/alembic/operations/batch.py +++ b/alembic/operations/batch.py @@ -265,7 +265,7 @@ class ApplyBatchImpl(object): if nullable is not None: existing.nullable = nullable if server_default is not False: - existing.server_default = server_default + sql_schema.DefaultClause(server_default)._set_parent(existing) if autoincrement is not None: existing.autoincrement = bool(autoincrement) diff --git a/docs/build/changelog.rst b/docs/build/changelog.rst index 187e7246..15c5f0cc 100644 --- a/docs/build/changelog.rst +++ b/docs/build/changelog.rst @@ -6,6 +6,13 @@ Changelog .. changelog:: :version: 0.8.4 + .. change:: + :tags: bug, batch + :tickets: 338 + + Fixed bug where the ``server_default`` parameter of ``alter_column()`` + would not function correctly in batch mode. + .. change:: :tags: bug, autogenerate :tickets: 337 diff --git a/tests/test_batch.py b/tests/test_batch.py index 813b15da..6842216c 100644 --- a/tests/test_batch.py +++ b/tests/test_batch.py @@ -339,6 +339,15 @@ class BatchApplyTest(TestBase): new_table = self._assert_impl(impl, colnames=['id', 'x', 'y', 'g']) eq_(new_table.c.g.name, 'g') + def test_add_server_default(self): + impl = self._simple_fixture() + impl.alter_column('tname', 'y', server_default="10") + new_table = self._assert_impl( + impl, ddl_contains="DEFAULT '10'") + eq_( + new_table.c.y.server_default.arg, "10" + ) + def test_rename_col_pk(self): impl = self._simple_fixture() impl.alter_column('tname', 'id', name='foobar')