|
|
@ -26,12 +26,12 @@ func NewMockConn(db *sql.DB) *MockConn {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Exec executes sql and returns the result
|
|
|
|
// Exec executes sql and returns the result
|
|
|
|
func (conn *MockConn) Exec(query string, args ...interface{}) (sql.Result, error) {
|
|
|
|
func (conn *MockConn) Exec(query string, args ...any) (sql.Result, error) {
|
|
|
|
return exec(conn.db, query, args...)
|
|
|
|
return exec(conn.db, query, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ExecCtx executes sql and returns the result
|
|
|
|
// ExecCtx executes sql and returns the result
|
|
|
|
func (conn *MockConn) ExecCtx(_ context.Context, query string, args ...interface{}) (sql.Result, error) {
|
|
|
|
func (conn *MockConn) ExecCtx(_ context.Context, query string, args ...any) (sql.Result, error) {
|
|
|
|
return exec(conn.db, query, args...)
|
|
|
|
return exec(conn.db, query, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -47,50 +47,50 @@ func (conn *MockConn) PrepareCtx(_ context.Context, query string) (sqlx.StmtSess
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// QueryRow executes sql and returns a query row
|
|
|
|
// QueryRow executes sql and returns a query row
|
|
|
|
func (conn *MockConn) QueryRow(v interface{}, q string, args ...interface{}) error {
|
|
|
|
func (conn *MockConn) QueryRow(v any, q string, args ...any) error {
|
|
|
|
return query(conn.db, func(rows *sql.Rows) error {
|
|
|
|
return query(conn.db, func(rows *sql.Rows) error {
|
|
|
|
return unmarshalRow(v, rows, true)
|
|
|
|
return unmarshalRow(v, rows, true)
|
|
|
|
}, q, args...)
|
|
|
|
}, q, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// QueryRowCtx executes sql and returns a query row
|
|
|
|
// QueryRowCtx executes sql and returns a query row
|
|
|
|
func (conn *MockConn) QueryRowCtx(_ context.Context, v interface{}, query string, args ...interface{}) error {
|
|
|
|
func (conn *MockConn) QueryRowCtx(_ context.Context, v any, query string, args ...any) error {
|
|
|
|
return conn.QueryRow(v, query, args...)
|
|
|
|
return conn.QueryRow(v, query, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// QueryRowPartial executes sql and returns a partial query row
|
|
|
|
// QueryRowPartial executes sql and returns a partial query row
|
|
|
|
func (conn *MockConn) QueryRowPartial(v interface{}, q string, args ...interface{}) error {
|
|
|
|
func (conn *MockConn) QueryRowPartial(v any, q string, args ...any) error {
|
|
|
|
return query(conn.db, func(rows *sql.Rows) error {
|
|
|
|
return query(conn.db, func(rows *sql.Rows) error {
|
|
|
|
return unmarshalRow(v, rows, false)
|
|
|
|
return unmarshalRow(v, rows, false)
|
|
|
|
}, q, args...)
|
|
|
|
}, q, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// QueryRowPartialCtx executes sql and returns a partial query row
|
|
|
|
// QueryRowPartialCtx executes sql and returns a partial query row
|
|
|
|
func (conn *MockConn) QueryRowPartialCtx(_ context.Context, v interface{}, query string, args ...interface{}) error {
|
|
|
|
func (conn *MockConn) QueryRowPartialCtx(_ context.Context, v any, query string, args ...any) error {
|
|
|
|
return conn.QueryRowPartial(v, query, args...)
|
|
|
|
return conn.QueryRowPartial(v, query, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// QueryRows executes sql and returns query rows
|
|
|
|
// QueryRows executes sql and returns query rows
|
|
|
|
func (conn *MockConn) QueryRows(v interface{}, q string, args ...interface{}) error {
|
|
|
|
func (conn *MockConn) QueryRows(v any, q string, args ...any) error {
|
|
|
|
return query(conn.db, func(rows *sql.Rows) error {
|
|
|
|
return query(conn.db, func(rows *sql.Rows) error {
|
|
|
|
return unmarshalRows(v, rows, true)
|
|
|
|
return unmarshalRows(v, rows, true)
|
|
|
|
}, q, args...)
|
|
|
|
}, q, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// QueryRowsCtx executes sql and returns query rows
|
|
|
|
// QueryRowsCtx executes sql and returns query rows
|
|
|
|
func (conn *MockConn) QueryRowsCtx(_ context.Context, v interface{}, query string, args ...interface{}) error {
|
|
|
|
func (conn *MockConn) QueryRowsCtx(_ context.Context, v any, query string, args ...any) error {
|
|
|
|
return conn.QueryRows(v, query, args...)
|
|
|
|
return conn.QueryRows(v, query, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// QueryRowsPartial executes sql and returns partial query rows
|
|
|
|
// QueryRowsPartial executes sql and returns partial query rows
|
|
|
|
func (conn *MockConn) QueryRowsPartial(v interface{}, q string, args ...interface{}) error {
|
|
|
|
func (conn *MockConn) QueryRowsPartial(v any, q string, args ...any) error {
|
|
|
|
return query(conn.db, func(rows *sql.Rows) error {
|
|
|
|
return query(conn.db, func(rows *sql.Rows) error {
|
|
|
|
return unmarshalRows(v, rows, false)
|
|
|
|
return unmarshalRows(v, rows, false)
|
|
|
|
}, q, args...)
|
|
|
|
}, q, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// QueryRowsPartialCtx executes sql and returns partial query rows
|
|
|
|
// QueryRowsPartialCtx executes sql and returns partial query rows
|
|
|
|
func (conn *MockConn) QueryRowsPartialCtx(_ context.Context, v interface{}, query string, args ...interface{}) error {
|
|
|
|
func (conn *MockConn) QueryRowsPartialCtx(_ context.Context, v any, query string, args ...any) error {
|
|
|
|
return conn.QueryRowsPartial(v, query, args...)
|
|
|
|
return conn.QueryRowsPartial(v, query, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -113,50 +113,50 @@ func (s statement) Close() error {
|
|
|
|
return s.stmt.Close()
|
|
|
|
return s.stmt.Close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s statement) Exec(args ...interface{}) (sql.Result, error) {
|
|
|
|
func (s statement) Exec(args ...any) (sql.Result, error) {
|
|
|
|
return execStmt(s.stmt, args...)
|
|
|
|
return execStmt(s.stmt, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s statement) ExecCtx(_ context.Context, args ...interface{}) (sql.Result, error) {
|
|
|
|
func (s statement) ExecCtx(_ context.Context, args ...any) (sql.Result, error) {
|
|
|
|
return s.Exec(args...)
|
|
|
|
return s.Exec(args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s statement) QueryRow(v interface{}, args ...interface{}) error {
|
|
|
|
func (s statement) QueryRow(v any, args ...any) error {
|
|
|
|
return queryStmt(s.stmt, func(rows *sql.Rows) error {
|
|
|
|
return queryStmt(s.stmt, func(rows *sql.Rows) error {
|
|
|
|
return unmarshalRow(v, rows, true)
|
|
|
|
return unmarshalRow(v, rows, true)
|
|
|
|
}, args...)
|
|
|
|
}, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s statement) QueryRowCtx(_ context.Context, v interface{}, args ...interface{}) error {
|
|
|
|
func (s statement) QueryRowCtx(_ context.Context, v any, args ...any) error {
|
|
|
|
return s.QueryRow(v, args...)
|
|
|
|
return s.QueryRow(v, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s statement) QueryRowPartial(v interface{}, args ...interface{}) error {
|
|
|
|
func (s statement) QueryRowPartial(v any, args ...any) error {
|
|
|
|
return queryStmt(s.stmt, func(rows *sql.Rows) error {
|
|
|
|
return queryStmt(s.stmt, func(rows *sql.Rows) error {
|
|
|
|
return unmarshalRow(v, rows, false)
|
|
|
|
return unmarshalRow(v, rows, false)
|
|
|
|
}, args...)
|
|
|
|
}, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s statement) QueryRowPartialCtx(_ context.Context, v interface{}, args ...interface{}) error {
|
|
|
|
func (s statement) QueryRowPartialCtx(_ context.Context, v any, args ...any) error {
|
|
|
|
return s.QueryRowPartial(v, args...)
|
|
|
|
return s.QueryRowPartial(v, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s statement) QueryRows(v interface{}, args ...interface{}) error {
|
|
|
|
func (s statement) QueryRows(v any, args ...any) error {
|
|
|
|
return queryStmt(s.stmt, func(rows *sql.Rows) error {
|
|
|
|
return queryStmt(s.stmt, func(rows *sql.Rows) error {
|
|
|
|
return unmarshalRows(v, rows, true)
|
|
|
|
return unmarshalRows(v, rows, true)
|
|
|
|
}, args...)
|
|
|
|
}, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s statement) QueryRowsCtx(_ context.Context, v interface{}, args ...interface{}) error {
|
|
|
|
func (s statement) QueryRowsCtx(_ context.Context, v any, args ...any) error {
|
|
|
|
return s.QueryRows(v, args...)
|
|
|
|
return s.QueryRows(v, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s statement) QueryRowsPartial(v interface{}, args ...interface{}) error {
|
|
|
|
func (s statement) QueryRowsPartial(v any, args ...any) error {
|
|
|
|
return queryStmt(s.stmt, func(rows *sql.Rows) error {
|
|
|
|
return queryStmt(s.stmt, func(rows *sql.Rows) error {
|
|
|
|
return unmarshalRows(v, rows, false)
|
|
|
|
return unmarshalRows(v, rows, false)
|
|
|
|
}, args...)
|
|
|
|
}, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s statement) QueryRowsPartialCtx(_ context.Context, v interface{}, args ...interface{}) error {
|
|
|
|
func (s statement) QueryRowsPartialCtx(_ context.Context, v any, args ...any) error {
|
|
|
|
return s.QueryRowsPartial(v, args...)
|
|
|
|
return s.QueryRowsPartial(v, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|