Chore: use any rather than interface{} (#74066)
This commit is contained in:
@@ -9,9 +9,9 @@ import (
|
||||
)
|
||||
|
||||
type Session interface {
|
||||
Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
|
||||
Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
|
||||
NamedExec(ctx context.Context, query string, arg interface{}) (sql.Result, error)
|
||||
Get(ctx context.Context, dest any, query string, args ...any) error
|
||||
Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
|
||||
NamedExec(ctx context.Context, query string, arg any) (sql.Result, error)
|
||||
}
|
||||
|
||||
type SessionDB struct {
|
||||
@@ -22,23 +22,23 @@ func GetSession(sqlxdb *sqlx.DB) *SessionDB {
|
||||
return &SessionDB{sqlxdb: sqlxdb}
|
||||
}
|
||||
|
||||
func (gs *SessionDB) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
|
||||
func (gs *SessionDB) Get(ctx context.Context, dest any, query string, args ...any) error {
|
||||
return gs.sqlxdb.GetContext(ctx, dest, gs.sqlxdb.Rebind(query), args...)
|
||||
}
|
||||
|
||||
func (gs *SessionDB) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
|
||||
func (gs *SessionDB) Select(ctx context.Context, dest any, query string, args ...any) error {
|
||||
return gs.sqlxdb.SelectContext(ctx, dest, gs.sqlxdb.Rebind(query), args...)
|
||||
}
|
||||
|
||||
func (gs *SessionDB) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) {
|
||||
func (gs *SessionDB) Query(ctx context.Context, query string, args ...any) (*sql.Rows, error) {
|
||||
return gs.sqlxdb.QueryContext(ctx, gs.sqlxdb.Rebind(query), args...)
|
||||
}
|
||||
|
||||
func (gs *SessionDB) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
|
||||
func (gs *SessionDB) Exec(ctx context.Context, query string, args ...any) (sql.Result, error) {
|
||||
return gs.sqlxdb.ExecContext(ctx, gs.sqlxdb.Rebind(query), args...)
|
||||
}
|
||||
|
||||
func (gs *SessionDB) NamedExec(ctx context.Context, query string, arg interface{}) (sql.Result, error) {
|
||||
func (gs *SessionDB) NamedExec(ctx context.Context, query string, arg any) (sql.Result, error) {
|
||||
return gs.sqlxdb.NamedExecContext(ctx, gs.sqlxdb.Rebind(query), arg)
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (gs *SessionDB) WithTransaction(ctx context.Context, callback func(*Session
|
||||
return tx.sqlxtx.Commit()
|
||||
}
|
||||
|
||||
func (gs *SessionDB) ExecWithReturningId(ctx context.Context, query string, args ...interface{}) (int64, error) {
|
||||
func (gs *SessionDB) ExecWithReturningId(ctx context.Context, query string, args ...any) (int64, error) {
|
||||
return execWithReturningId(ctx, gs.driverName(), query, gs, args...)
|
||||
}
|
||||
|
||||
@@ -76,19 +76,19 @@ type SessionTx struct {
|
||||
sqlxtx *sqlx.Tx
|
||||
}
|
||||
|
||||
func (gtx *SessionTx) NamedExec(ctx context.Context, query string, arg interface{}) (sql.Result, error) {
|
||||
func (gtx *SessionTx) NamedExec(ctx context.Context, query string, arg any) (sql.Result, error) {
|
||||
return gtx.sqlxtx.NamedExecContext(ctx, gtx.sqlxtx.Rebind(query), arg)
|
||||
}
|
||||
|
||||
func (gtx *SessionTx) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
|
||||
func (gtx *SessionTx) Exec(ctx context.Context, query string, args ...any) (sql.Result, error) {
|
||||
return gtx.sqlxtx.ExecContext(ctx, gtx.sqlxtx.Rebind(query), args...)
|
||||
}
|
||||
|
||||
func (gtx *SessionTx) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) {
|
||||
func (gtx *SessionTx) Query(ctx context.Context, query string, args ...any) (*sql.Rows, error) {
|
||||
return gtx.sqlxtx.QueryContext(ctx, gtx.sqlxtx.Rebind(query), args...)
|
||||
}
|
||||
|
||||
func (gtx *SessionTx) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
|
||||
func (gtx *SessionTx) Get(ctx context.Context, dest any, query string, args ...any) error {
|
||||
return gtx.sqlxtx.GetContext(ctx, dest, gtx.sqlxtx.Rebind(query), args...)
|
||||
}
|
||||
|
||||
@@ -96,11 +96,11 @@ func (gtx *SessionTx) driverName() string {
|
||||
return gtx.sqlxtx.DriverName()
|
||||
}
|
||||
|
||||
func (gtx *SessionTx) ExecWithReturningId(ctx context.Context, query string, args ...interface{}) (int64, error) {
|
||||
func (gtx *SessionTx) ExecWithReturningId(ctx context.Context, query string, args ...any) (int64, error) {
|
||||
return execWithReturningId(ctx, gtx.driverName(), query, gtx, args...)
|
||||
}
|
||||
|
||||
func execWithReturningId(ctx context.Context, driverName string, query string, sess Session, args ...interface{}) (int64, error) {
|
||||
func execWithReturningId(ctx context.Context, driverName string, query string, sess Session, args ...any) (int64, error) {
|
||||
supported := false
|
||||
var id int64
|
||||
if driverName == "postgres" {
|
||||
|
||||
Reference in New Issue
Block a user