mirror of
https://github.com/nalgeon/redka.git
synced 2025-10-29 10:32:33 +08:00
refactor: sqlx - delete TypedError
This commit is contained in:
@@ -453,7 +453,7 @@ func (tx *Tx) set(key string, field string, value any) error {
|
|||||||
}
|
}
|
||||||
_, err := tx.tx.Exec(sqlSet, args...)
|
_, err := tx.tx.Exec(sqlSet, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sqlx.TypedError(err)
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ func set(tx sqlx.Tx, key string, value any, at time.Time) error {
|
|||||||
}
|
}
|
||||||
_, err := tx.Exec(sqlSet, args...)
|
_, err := tx.Exec(sqlSet, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sqlx.TypedError(err)
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -260,7 +260,7 @@ func update(tx sqlx.Tx, key string, value any) error {
|
|||||||
}
|
}
|
||||||
_, err := tx.Exec(sqlUpdate, args...)
|
_, err := tx.Exec(sqlUpdate, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sqlx.TypedError(err)
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ func (c InterCmd) store(tx sqlx.Tx) (int, error) {
|
|||||||
|
|
||||||
res, err := tx.Exec(query, args...)
|
res, err := tx.Exec(query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, sqlx.TypedError(err)
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the number of elements in the resulting set.
|
// Return the number of elements in the resulting set.
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ func (tx *Tx) Incr(key string, elem any, delta float64) (float64, error) {
|
|||||||
}
|
}
|
||||||
_, err := tx.tx.Exec(sqlIncr1, args...)
|
_, err := tx.tx.Exec(sqlIncr1, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, sqlx.TypedError(err)
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var score float64
|
var score float64
|
||||||
@@ -373,7 +373,7 @@ func (tx *Tx) add(key string, elem any, score float64) error {
|
|||||||
|
|
||||||
_, err := tx.tx.Exec(sqlAdd, args...)
|
_, err := tx.tx.Exec(sqlAdd, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sqlx.TypedError(err)
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ func (c UnionCmd) store(tx sqlx.Tx) (int, error) {
|
|||||||
|
|
||||||
res, err := tx.Exec(query, args...)
|
res, err := tx.Exec(query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, sqlx.TypedError(err)
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the number of elements in the resulting set.
|
// Return the number of elements in the resulting set.
|
||||||
|
|||||||
@@ -67,8 +67,3 @@ func Select[T any](db Tx, query string, args []any,
|
|||||||
|
|
||||||
return vals, err
|
return vals, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns typed errors for some specific cases.
|
|
||||||
func TypedError(err error) error {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user