mirror of https://github.com/go-gorm/gorm.git
Don't scan last insert id 0
This commit is contained in:
parent
6ed697dd02
commit
c3f52cee8b
|
@ -78,7 +78,9 @@ func Create(config *Config) func(db *gorm.DB) {
|
|||
}
|
||||
}
|
||||
case reflect.Struct:
|
||||
db.Statement.Schema.PrioritizedPrimaryField.Set(db.Statement.ReflectValue, insertID)
|
||||
if insertID > 0 {
|
||||
db.Statement.Schema.PrioritizedPrimaryField.Set(db.Statement.ReflectValue, insertID)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
db.AddError(err)
|
||||
|
|
Loading…
Reference in New Issue