Merge ed02d1ba0326aaf0e18d222d3ad1e800adfb900f into 572d0a0ab1eb75410a2729e96239152d1da7a91f
This commit is contained in:
commit
1b8c18d04d
@ -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{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user