From 66982a704744b325a251858d05aa9af03e4c4c0e Mon Sep 17 00:00:00 2001 From: John Mick Date: Tue, 7 Mar 2017 11:10:14 +0100 Subject: [PATCH] Remove SET_IDENTITY_INSERT for transactions in MS SQL SET_IDENTITY_INSERT should be handled by each individual developer to avoid extra queries to the database. --- dialects/mssql/mssql.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/dialects/mssql/mssql.go b/dialects/mssql/mssql.go index c3c81aa2..7541b222 100644 --- a/dialects/mssql/mssql.go +++ b/dialects/mssql/mssql.go @@ -11,14 +11,7 @@ import ( "github.com/jinzhu/gorm" ) -func setIdentityInsert(scope *gorm.Scope) { - if scope.Dialect().GetName() == "mssql" { - scope.NewDB().Exec(fmt.Sprintf("SET IDENTITY_INSERT %v ON", scope.TableName())) - } -} - func init() { - gorm.DefaultCallback.Create().After("gorm:begin_transaction").Register("mssql:set_identity_insert", setIdentityInsert) gorm.RegisterDialect("mssql", &mssql{}) }