From 22451a4212dac635f67c6db6091a62c9dce14324 Mon Sep 17 00:00:00 2001 From: donkopotamus Date: Thu, 28 Nov 2013 16:30:32 +1300 Subject: [PATCH] Ensure a commit is followed by a GO --- alembic/ddl/mssql.py | 5 +++++ tests/test_mssql.py | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) 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'" # ) - -- 2.47.3