chore: change interface{} to any (#2818)
* chore: change interface{} to any
* chore: update goctl version to 1.5.0
* chore: update goctl deps
This commit is contained in:
@@ -17,18 +17,18 @@ var ErrNotFound = sql.ErrNoRows
|
||||
type (
|
||||
// Session stands for raw connections or transaction sessions
|
||||
Session interface {
|
||||
Exec(query string, args ...interface{}) (sql.Result, error)
|
||||
ExecCtx(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
|
||||
Exec(query string, args ...any) (sql.Result, error)
|
||||
ExecCtx(ctx context.Context, query string, args ...any) (sql.Result, error)
|
||||
Prepare(query string) (StmtSession, error)
|
||||
PrepareCtx(ctx context.Context, query string) (StmtSession, error)
|
||||
QueryRow(v interface{}, query string, args ...interface{}) error
|
||||
QueryRowCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error
|
||||
QueryRowPartial(v interface{}, query string, args ...interface{}) error
|
||||
QueryRowPartialCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error
|
||||
QueryRows(v interface{}, query string, args ...interface{}) error
|
||||
QueryRowsCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error
|
||||
QueryRowsPartial(v interface{}, query string, args ...interface{}) error
|
||||
QueryRowsPartialCtx(ctx context.Context, v interface{}, query string, args ...interface{}) error
|
||||
QueryRow(v any, query string, args ...any) error
|
||||
QueryRowCtx(ctx context.Context, v any, query string, args ...any) error
|
||||
QueryRowPartial(v any, query string, args ...any) error
|
||||
QueryRowPartialCtx(ctx context.Context, v any, query string, args ...any) error
|
||||
QueryRows(v any, query string, args ...any) error
|
||||
QueryRowsCtx(ctx context.Context, v any, query string, args ...any) error
|
||||
QueryRowsPartial(v any, query string, args ...any) error
|
||||
QueryRowsPartialCtx(ctx context.Context, v any, query string, args ...any) error
|
||||
}
|
||||
|
||||
// SqlConn only stands for raw connections, so Transact method can be called.
|
||||
@@ -47,16 +47,16 @@ type (
|
||||
// StmtSession interface represents a session that can be used to execute statements.
|
||||
StmtSession interface {
|
||||
Close() error
|
||||
Exec(args ...interface{}) (sql.Result, error)
|
||||
ExecCtx(ctx context.Context, args ...interface{}) (sql.Result, error)
|
||||
QueryRow(v interface{}, args ...interface{}) error
|
||||
QueryRowCtx(ctx context.Context, v interface{}, args ...interface{}) error
|
||||
QueryRowPartial(v interface{}, args ...interface{}) error
|
||||
QueryRowPartialCtx(ctx context.Context, v interface{}, args ...interface{}) error
|
||||
QueryRows(v interface{}, args ...interface{}) error
|
||||
QueryRowsCtx(ctx context.Context, v interface{}, args ...interface{}) error
|
||||
QueryRowsPartial(v interface{}, args ...interface{}) error
|
||||
QueryRowsPartialCtx(ctx context.Context, v interface{}, args ...interface{}) error
|
||||
Exec(args ...any) (sql.Result, error)
|
||||
ExecCtx(ctx context.Context, args ...any) (sql.Result, error)
|
||||
QueryRow(v any, args ...any) error
|
||||
QueryRowCtx(ctx context.Context, v any, args ...any) error
|
||||
QueryRowPartial(v any, args ...any) error
|
||||
QueryRowPartialCtx(ctx context.Context, v any, args ...any) error
|
||||
QueryRows(v any, args ...any) error
|
||||
QueryRowsCtx(ctx context.Context, v any, args ...any) error
|
||||
QueryRowsPartial(v any, args ...any) error
|
||||
QueryRowsPartialCtx(ctx context.Context, v any, args ...any) error
|
||||
}
|
||||
|
||||
// thread-safe
|
||||
@@ -73,10 +73,10 @@ type (
|
||||
connProvider func() (*sql.DB, error)
|
||||
|
||||
sessionConn interface {
|
||||
Exec(query string, args ...interface{}) (sql.Result, error)
|
||||
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
|
||||
Query(query string, args ...interface{}) (*sql.Rows, error)
|
||||
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
|
||||
Exec(query string, args ...any) (sql.Result, error)
|
||||
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
|
||||
Query(query string, args ...any) (*sql.Rows, error)
|
||||
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
|
||||
}
|
||||
|
||||
statement struct {
|
||||
@@ -85,10 +85,10 @@ type (
|
||||
}
|
||||
|
||||
stmtConn interface {
|
||||
Exec(args ...interface{}) (sql.Result, error)
|
||||
ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error)
|
||||
Query(args ...interface{}) (*sql.Rows, error)
|
||||
QueryContext(ctx context.Context, args ...interface{}) (*sql.Rows, error)
|
||||
Exec(args ...any) (sql.Result, error)
|
||||
ExecContext(ctx context.Context, args ...any) (sql.Result, error)
|
||||
Query(args ...any) (*sql.Rows, error)
|
||||
QueryContext(ctx context.Context, args ...any) (*sql.Rows, error)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -131,11 +131,11 @@ func NewSqlConnFromDB(db *sql.DB, opts ...SqlOption) SqlConn {
|
||||
return conn
|
||||
}
|
||||
|
||||
func (db *commonSqlConn) Exec(q string, args ...interface{}) (result sql.Result, err error) {
|
||||
func (db *commonSqlConn) Exec(q string, args ...any) (result sql.Result, err error) {
|
||||
return db.ExecCtx(context.Background(), q, args...)
|
||||
}
|
||||
|
||||
func (db *commonSqlConn) ExecCtx(ctx context.Context, q string, args ...interface{}) (
|
||||
func (db *commonSqlConn) ExecCtx(ctx context.Context, q string, args ...any) (
|
||||
result sql.Result, err error) {
|
||||
ctx, span := startSpan(ctx, "Exec")
|
||||
defer func() {
|
||||
@@ -196,12 +196,12 @@ func (db *commonSqlConn) PrepareCtx(ctx context.Context, query string) (stmt Stm
|
||||
return
|
||||
}
|
||||
|
||||
func (db *commonSqlConn) QueryRow(v interface{}, q string, args ...interface{}) error {
|
||||
func (db *commonSqlConn) QueryRow(v any, q string, args ...any) error {
|
||||
return db.QueryRowCtx(context.Background(), v, q, args...)
|
||||
}
|
||||
|
||||
func (db *commonSqlConn) QueryRowCtx(ctx context.Context, v interface{}, q string,
|
||||
args ...interface{}) (err error) {
|
||||
func (db *commonSqlConn) QueryRowCtx(ctx context.Context, v any, q string,
|
||||
args ...any) (err error) {
|
||||
ctx, span := startSpan(ctx, "QueryRow")
|
||||
defer func() {
|
||||
endSpan(span, err)
|
||||
@@ -212,12 +212,12 @@ func (db *commonSqlConn) QueryRowCtx(ctx context.Context, v interface{}, q strin
|
||||
}, q, args...)
|
||||
}
|
||||
|
||||
func (db *commonSqlConn) QueryRowPartial(v interface{}, q string, args ...interface{}) error {
|
||||
func (db *commonSqlConn) QueryRowPartial(v any, q string, args ...any) error {
|
||||
return db.QueryRowPartialCtx(context.Background(), v, q, args...)
|
||||
}
|
||||
|
||||
func (db *commonSqlConn) QueryRowPartialCtx(ctx context.Context, v interface{},
|
||||
q string, args ...interface{}) (err error) {
|
||||
func (db *commonSqlConn) QueryRowPartialCtx(ctx context.Context, v any,
|
||||
q string, args ...any) (err error) {
|
||||
ctx, span := startSpan(ctx, "QueryRowPartial")
|
||||
defer func() {
|
||||
endSpan(span, err)
|
||||
@@ -228,12 +228,12 @@ func (db *commonSqlConn) QueryRowPartialCtx(ctx context.Context, v interface{},
|
||||
}, q, args...)
|
||||
}
|
||||
|
||||
func (db *commonSqlConn) QueryRows(v interface{}, q string, args ...interface{}) error {
|
||||
func (db *commonSqlConn) QueryRows(v any, q string, args ...any) error {
|
||||
return db.QueryRowsCtx(context.Background(), v, q, args...)
|
||||
}
|
||||
|
||||
func (db *commonSqlConn) QueryRowsCtx(ctx context.Context, v interface{}, q string,
|
||||
args ...interface{}) (err error) {
|
||||
func (db *commonSqlConn) QueryRowsCtx(ctx context.Context, v any, q string,
|
||||
args ...any) (err error) {
|
||||
ctx, span := startSpan(ctx, "QueryRows")
|
||||
defer func() {
|
||||
endSpan(span, err)
|
||||
@@ -244,12 +244,12 @@ func (db *commonSqlConn) QueryRowsCtx(ctx context.Context, v interface{}, q stri
|
||||
}, q, args...)
|
||||
}
|
||||
|
||||
func (db *commonSqlConn) QueryRowsPartial(v interface{}, q string, args ...interface{}) error {
|
||||
func (db *commonSqlConn) QueryRowsPartial(v any, q string, args ...any) error {
|
||||
return db.QueryRowsPartialCtx(context.Background(), v, q, args...)
|
||||
}
|
||||
|
||||
func (db *commonSqlConn) QueryRowsPartialCtx(ctx context.Context, v interface{},
|
||||
q string, args ...interface{}) (err error) {
|
||||
func (db *commonSqlConn) QueryRowsPartialCtx(ctx context.Context, v any,
|
||||
q string, args ...any) (err error) {
|
||||
ctx, span := startSpan(ctx, "QueryRowsPartial")
|
||||
defer func() {
|
||||
endSpan(span, err)
|
||||
@@ -296,7 +296,7 @@ func (db *commonSqlConn) acceptable(err error) bool {
|
||||
}
|
||||
|
||||
func (db *commonSqlConn) queryRows(ctx context.Context, scanner func(*sql.Rows) error,
|
||||
q string, args ...interface{}) (err error) {
|
||||
q string, args ...any) (err error) {
|
||||
var qerr error
|
||||
err = db.brk.DoWithAcceptable(func() error {
|
||||
conn, err := db.connProv()
|
||||
@@ -323,11 +323,11 @@ func (s statement) Close() error {
|
||||
return s.stmt.Close()
|
||||
}
|
||||
|
||||
func (s statement) Exec(args ...interface{}) (sql.Result, error) {
|
||||
func (s statement) Exec(args ...any) (sql.Result, error) {
|
||||
return s.ExecCtx(context.Background(), args...)
|
||||
}
|
||||
|
||||
func (s statement) ExecCtx(ctx context.Context, args ...interface{}) (result sql.Result, err error) {
|
||||
func (s statement) ExecCtx(ctx context.Context, args ...any) (result sql.Result, err error) {
|
||||
ctx, span := startSpan(ctx, "Exec")
|
||||
defer func() {
|
||||
endSpan(span, err)
|
||||
@@ -336,11 +336,11 @@ func (s statement) ExecCtx(ctx context.Context, args ...interface{}) (result sql
|
||||
return execStmt(ctx, s.stmt, s.query, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRow(v interface{}, args ...interface{}) error {
|
||||
func (s statement) QueryRow(v any, args ...any) error {
|
||||
return s.QueryRowCtx(context.Background(), v, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRowCtx(ctx context.Context, v interface{}, args ...interface{}) (err error) {
|
||||
func (s statement) QueryRowCtx(ctx context.Context, v any, args ...any) (err error) {
|
||||
ctx, span := startSpan(ctx, "QueryRow")
|
||||
defer func() {
|
||||
endSpan(span, err)
|
||||
@@ -351,11 +351,11 @@ func (s statement) QueryRowCtx(ctx context.Context, v interface{}, args ...inter
|
||||
}, s.query, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRowPartial(v interface{}, args ...interface{}) error {
|
||||
func (s statement) QueryRowPartial(v any, args ...any) error {
|
||||
return s.QueryRowPartialCtx(context.Background(), v, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRowPartialCtx(ctx context.Context, v interface{}, args ...interface{}) (err error) {
|
||||
func (s statement) QueryRowPartialCtx(ctx context.Context, v any, args ...any) (err error) {
|
||||
ctx, span := startSpan(ctx, "QueryRowPartial")
|
||||
defer func() {
|
||||
endSpan(span, err)
|
||||
@@ -366,11 +366,11 @@ func (s statement) QueryRowPartialCtx(ctx context.Context, v interface{}, args .
|
||||
}, s.query, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRows(v interface{}, args ...interface{}) error {
|
||||
func (s statement) QueryRows(v any, args ...any) error {
|
||||
return s.QueryRowsCtx(context.Background(), v, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRowsCtx(ctx context.Context, v interface{}, args ...interface{}) (err error) {
|
||||
func (s statement) QueryRowsCtx(ctx context.Context, v any, args ...any) (err error) {
|
||||
ctx, span := startSpan(ctx, "QueryRows")
|
||||
defer func() {
|
||||
endSpan(span, err)
|
||||
@@ -381,11 +381,11 @@ func (s statement) QueryRowsCtx(ctx context.Context, v interface{}, args ...inte
|
||||
}, s.query, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRowsPartial(v interface{}, args ...interface{}) error {
|
||||
func (s statement) QueryRowsPartial(v any, args ...any) error {
|
||||
return s.QueryRowsPartialCtx(context.Background(), v, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRowsPartialCtx(ctx context.Context, v interface{}, args ...interface{}) (err error) {
|
||||
func (s statement) QueryRowsPartialCtx(ctx context.Context, v any, args ...any) (err error) {
|
||||
ctx, span := startSpan(ctx, "QueryRowsPartial")
|
||||
defer func() {
|
||||
endSpan(span, err)
|
||||
|
||||
Reference in New Issue
Block a user