mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-25 19:39:46 +01:00
Fix error comparisons
This commit is contained in:
parent
7b0a8f47de
commit
db67c1277e
27 changed files with 93 additions and 73 deletions
|
|
@ -2,6 +2,7 @@ package persistence
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -146,7 +147,7 @@ func (r sqlRepository) queryOne(sq Sqlizer, response interface{}) error {
|
|||
}
|
||||
start := time.Now()
|
||||
err = r.ormer.Raw(query, args...).QueryRow(response)
|
||||
if err == orm.ErrNoRows {
|
||||
if errors.Is(err, orm.ErrNoRows) {
|
||||
r.logSQL(query, args, nil, 0, start)
|
||||
return model.ErrNotFound
|
||||
}
|
||||
|
|
@ -161,7 +162,7 @@ func (r sqlRepository) queryAll(sq Sqlizer, response interface{}) error {
|
|||
}
|
||||
start := time.Now()
|
||||
c, err := r.ormer.Raw(query, args...).QueryRows(response)
|
||||
if err == orm.ErrNoRows {
|
||||
if errors.Is(err, orm.ErrNoRows) {
|
||||
r.logSQL(query, args, nil, c, start)
|
||||
return model.ErrNotFound
|
||||
}
|
||||
|
|
@ -224,7 +225,7 @@ func (r sqlRepository) put(id string, m interface{}, colsToUpdate ...string) (ne
|
|||
func (r sqlRepository) delete(cond Sqlizer) error {
|
||||
del := Delete(r.tableName).Where(cond)
|
||||
_, err := r.executeSQL(del)
|
||||
if err == orm.ErrNoRows {
|
||||
if errors.Is(err, orm.ErrNoRows) {
|
||||
return model.ErrNotFound
|
||||
}
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue