mirror of https://github.com/go-gorm/gorm.git
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.
This commit is contained in:
parent
572d0a0ab1
commit
66982a7047
|
@ -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{})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue