File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ func (db *DB) Save(value interface{}) (tx *DB) {
105105
106106 if tx .Error == nil && tx .RowsAffected == 0 && ! tx .DryRun && ! selectedUpdate {
107107 result := reflect .New (tx .Statement .Schema .ModelType ).Interface ()
108- if err := tx .Session (& Session {}).Take ( result ). Error ; errors . Is ( err , ErrRecordNotFound ) {
108+ if result := tx .Session (& Session {}).Limit ( 1 ). Find ( result ); result . RowsAffected == 0 {
109109 return tx .Create (value )
110110 }
111111 }
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ require (
88 github.com/jinzhu/now v1.1.5
99 github.com/lib/pq v1.10.5
1010 github.com/mattn/go-sqlite3 v1.14.12 // indirect
11- golang.org/x/crypto v0.0.0-20220408190544-5352b0902921 // indirect
11+ golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
1212 gorm.io/driver/mysql v1.3.3
1313 gorm.io/driver/postgres v1.3.4
1414 gorm.io/driver/sqlite v1.3.1
You can’t perform that action at this time.
0 commit comments