From: donkopotamus Date: Thu, 28 Nov 2013 03:30:32 +0000 (+1300) Subject: Ensure a commit is followed by a GO X-Git-Tag: rel_0_6_2~13^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22451a4212dac635f67c6db6091a62c9dce14324;p=thirdparty%2Fsqlalchemy%2Falembic.git Ensure a commit is followed by a GO --- diff --git a/alembic/ddl/mssql.py b/alembic/ddl/mssql.py index 41252512..e4f2e9ae 100644 --- a/alembic/ddl/mssql.py +++ b/alembic/ddl/mssql.py @@ -25,6 +25,11 @@ class MSSQLImpl(DefaultImpl): def emit_begin(self): self.static_output("BEGIN TRANSACTION" + self.command_terminator) + def emit_commit(self): + super(MSSQLImpl, self).emit_commit() + if self.as_sql and self.batch_separator: + self.static_output(self.batch_separator) + def alter_column(self, table_name, column_name, nullable=None, server_default=False, diff --git a/tests/test_mssql.py b/tests/test_mssql.py index a320d4aa..74bda8b7 100644 --- a/tests/test_mssql.py +++ b/tests/test_mssql.py @@ -23,11 +23,13 @@ class FullEnvironmentTests(TestCase): def teardown_class(cls): clear_staging_env() - def test_begin_comit(self): + def test_begin_commit(self): with capture_context_buffer(transactional_ddl=True) as buf: command.upgrade(self.cfg, self.a, sql=True) assert "BEGIN TRANSACTION;" in buf.getvalue() - assert "COMMIT;" in buf.getvalue() + + # ensure ends in COMMIT; GO + assert [x for x in buf.getvalue().splitlines() if x][-2:] == ['COMMIT;', 'GO'] def test_batch_separator_default(self): with capture_context_buffer() as buf: @@ -176,4 +178,3 @@ class OpTest(TestCase): # context.assert_( # "EXEC sp_rename 'y.t.c', 'x', 'COLUMN'" # ) -