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
efcabc8be3
commit
1c62bf1e57
2
main.go
2
main.go
|
@ -444,7 +444,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