]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Ensure a commit is followed by a GO
authordonkopotamus <derek.harland@finq.co.nz>
Thu, 28 Nov 2013 03:30:32 +0000 (16:30 +1300)
committerdonkopotamus <derek.harland@finq.co.nz>
Thu, 28 Nov 2013 03:30:32 +0000 (16:30 +1300)
alembic/ddl/mssql.py
tests/test_mssql.py

index 4125251266caacbb4d655149d219808400f0d984..e4f2e9ae8906d5ff3a3bbcdd52300fa880722cbc 100644 (file)
@@ -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,
index a320d4aafd7e14e988f17cb59bd015ea97145db8..74bda8b789534a6ce765ec489e401675b99b9157 100644 (file)
@@ -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'"
     #    )
-