mirror of https://github.com/go-gorm/gorm.git
Remove ErrRecordNotFound error from log when using Save
This commit is contained in:
parent
ce53ea53ee
commit
d421c67ef5
|
@ -105,7 +105,7 @@ func (db *DB) Save(value interface{}) (tx *DB) {
|
|||
|
||||
if tx.Error == nil && tx.RowsAffected == 0 && !tx.DryRun && !selectedUpdate {
|
||||
result := reflect.New(tx.Statement.Schema.ModelType).Interface()
|
||||
if err := tx.Session(&Session{}).Take(result).Error; errors.Is(err, ErrRecordNotFound) {
|
||||
if result := tx.Session(&Session{}).Limit(1).Find(result); result.RowsAffected == 0 {
|
||||
return tx.Create(value)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ require (
|
|||
github.com/jinzhu/now v1.1.5
|
||||
github.com/lib/pq v1.10.5
|
||||
github.com/mattn/go-sqlite3 v1.14.12 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220408190544-5352b0902921 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
|
||||
gorm.io/driver/mysql v1.3.3
|
||||
gorm.io/driver/postgres v1.3.4
|
||||
gorm.io/driver/sqlite v1.3.1
|
||||
|
|
Loading…
Reference in New Issue