diff --git a/scan.go b/scan.go index acd637a4..e82e3f07 100644 --- a/scan.go +++ b/scan.go @@ -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) } }