Fix context cancel error, close #4259, close #4260

This commit is contained in:
Jinzhu 2021-04-09 09:35:41 +08:00
parent 8cfa9d98f0
commit 673053f56a
1 changed files with 5 additions and 1 deletions

View File

@ -241,7 +241,11 @@ func Scan(rows *sql.Rows, db *DB, initialized bool) {
}
}
if db.RowsAffected == 0 && db.Statement.RaiseErrorOnNotFound {
if err := rows.Err(); err != nil && err != db.Error {
db.AddError(err)
}
if db.RowsAffected == 0 && db.Statement.RaiseErrorOnNotFound && db.Error == nil {
db.AddError(ErrRecordNotFound)
}
}