You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
428 B
17 lines
428 B
package sqlserver
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/callbacks"
|
|
)
|
|
|
|
var updateFunc = callbacks.Update(&callbacks.Config{})
|
|
|
|
func Update(db *gorm.DB) {
|
|
if db.Statement.Schema != nil && db.Statement.Schema.PrioritizedPrimaryField != nil && db.Statement.Schema.PrioritizedPrimaryField.AutoIncrement {
|
|
db.Statement.Omits = append(db.Statement.Omits, db.Statement.Schema.PrioritizedPrimaryField.DBName)
|
|
}
|
|
|
|
updateFunc(db)
|
|
}
|