Mike Bayer committed 0522003

- enable SAVEPOINT support fully, remove warning, [ticket:822].
It's not known what the potential "data loss" issues are, tests seem to pass.

  • Participants
  • Parent commits 7794e8d

Comments (0)

Files changed (4)

 - mssql
+  - [feature] lifted the restriction on SAVEPOINT
+    for SQL Server.  All tests pass using it,
+    it's not known if there are deeper issues
+    however.   [ticket:822]
   - [bug] repaired the with_hint() feature which
     wasn't implemented correctly on MSSQL - 
     usually used for the "WITH (NOLOCK)" hint

File lib/sqlalchemy/dialects/mssql/

         return 'DATEPART("%s", %s)' % \
                         (field, self.process(extract.expr, **kw))
+    def visit_savepoint(self, savepoint_stmt):
+        return "SAVE TRANSACTION %s" % self.preparer.format_savepoint(savepoint_stmt)
     def visit_rollback_to_savepoint(self, savepoint_stmt):
         return ("ROLLBACK TRANSACTION %s" 
                 % self.preparer.format_savepoint(savepoint_stmt))
         super(MSDialect, self).__init__(**opts)
     def do_savepoint(self, connection, name):
-        util.warn("Savepoint support in mssql is experimental and "
-                  "may lead to data loss.")
+        # give the DBAPI a push
         connection.execute("IF @@TRANCOUNT = 0 BEGIN TRANSACTION")
-        connection.execute("SAVE TRANSACTION %s" % name)
+        super(MSDialect, self).do_savepoint(connection, name)
     def do_release_savepoint(self, connection, name):
+        # SQL Server does not support RELEASE SAVEPOINT
     def initialize(self, connection):

File test/lib/

                 'SQL Server 2005+ is required for independent connections'),
+def updateable_autoincrement_pks(fn):
+    """Target must support UPDATE on autoincrement/integer primary key."""
+    return _chain_decorators_on(
+        fn,
+        no_support('mssql', "IDENTITY cols can't be updated"),
+        no_support('sybase', "IDENTITY cols can't be updated"),
+    )
 def isolation_level(fn):
     return _chain_decorators_on(
     """Target database must support savepoints."""
     return _chain_decorators_on(
-        emits_warning_on('mssql', 'Savepoint support in mssql is experimental and may lead to data loss.'),
         no_support('access', 'savepoints not supported'),
         no_support('sqlite', 'savepoints not supported'),
         no_support('sybase', 'savepoints not supported'),

File test/orm/

+    @testing.requires.updateable_autoincrement_pks
     def test_accounting_no_select_needed(self):
         """test that flush accounting works on non-expired instances
         when autocommit=True/expire_on_commit=True."""