Merge ed02d1ba0326aaf0e18d222d3ad1e800adfb900f into 572d0a0ab1eb75410a2729e96239152d1da7a91f

This commit is contained in:
John Mick 2017-03-16 14:16:45 +00:00 committed by GitHub
commit 1b8c18d04d

View File

@ -11,14 +11,7 @@ import (
"github.com/jinzhu/gorm" "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() { func init() {
gorm.DefaultCallback.Create().After("gorm:begin_transaction").Register("mssql:set_identity_insert", setIdentityInsert)
gorm.RegisterDialect("mssql", &mssql{}) gorm.RegisterDialect("mssql", &mssql{})
} }