mirror of https://github.com/go-gorm/gorm.git
fix save err when specify a table name
s.New() will clear all search conditions and search value,when I use Table() to set a table name. Then FirstOrCreate() will use struct name as my database table name,so It doesn't work.
This commit is contained in:
parent
712c465560
commit
781a818390
2
main.go
2
main.go
|
@ -466,7 +466,7 @@ func (s *DB) Save(value interface{}) *DB {
|
|||
if !scope.PrimaryKeyZero() {
|
||||
newDB := scope.callCallbacks(s.parent.callbacks.updates).db
|
||||
if newDB.Error == nil && newDB.RowsAffected == 0 {
|
||||
return s.New().FirstOrCreate(value)
|
||||
return s.FirstOrCreate(value)
|
||||
}
|
||||
return newDB
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue