Fix error comparisons

This commit is contained in:
Deluan
2022-09-30 18:54:25 -04:00
parent 7b0a8f47de
commit db67c1277e
27 changed files with 93 additions and 73 deletions
+4 -3
View File
@@ -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