chore: update go-zero to v1.3.1 in goctl (#1599)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package mocksql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
@@ -29,12 +30,22 @@ func (conn *MockConn) Exec(query string, args ...interface{}) (sql.Result, error
|
||||
return exec(conn.db, query, args...)
|
||||
}
|
||||
|
||||
// ExecCtx executes sql and returns the result
|
||||
func (conn *MockConn) ExecCtx(_ context.Context, query string, args ...interface{}) (sql.Result, error) {
|
||||
return exec(conn.db, query, args...)
|
||||
}
|
||||
|
||||
// Prepare executes sql by sql.DB
|
||||
func (conn *MockConn) Prepare(query string) (sqlx.StmtSession, error) {
|
||||
st, err := conn.db.Prepare(query)
|
||||
return statement{stmt: st}, err
|
||||
}
|
||||
|
||||
// PrepareCtx executes sql by sql.DB
|
||||
func (conn *MockConn) PrepareCtx(_ context.Context, query string) (sqlx.StmtSession, error) {
|
||||
return conn.Prepare(query)
|
||||
}
|
||||
|
||||
// QueryRow executes sql and returns a query row
|
||||
func (conn *MockConn) QueryRow(v interface{}, q string, args ...interface{}) error {
|
||||
return query(conn.db, func(rows *sql.Rows) error {
|
||||
@@ -42,6 +53,11 @@ func (conn *MockConn) QueryRow(v interface{}, q string, args ...interface{}) err
|
||||
}, q, args...)
|
||||
}
|
||||
|
||||
// QueryRowCtx executes sql and returns a query row
|
||||
func (conn *MockConn) QueryRowCtx(_ context.Context, v interface{}, query string, args ...interface{}) error {
|
||||
return conn.QueryRow(v, query, args...)
|
||||
}
|
||||
|
||||
// QueryRowPartial executes sql and returns a partial query row
|
||||
func (conn *MockConn) QueryRowPartial(v interface{}, q string, args ...interface{}) error {
|
||||
return query(conn.db, func(rows *sql.Rows) error {
|
||||
@@ -49,6 +65,11 @@ func (conn *MockConn) QueryRowPartial(v interface{}, q string, args ...interface
|
||||
}, q, args...)
|
||||
}
|
||||
|
||||
// QueryRowPartialCtx executes sql and returns a partial query row
|
||||
func (conn *MockConn) QueryRowPartialCtx(_ context.Context, v interface{}, query string, args ...interface{}) error {
|
||||
return conn.QueryRowPartial(v, query, args...)
|
||||
}
|
||||
|
||||
// QueryRows executes sql and returns query rows
|
||||
func (conn *MockConn) QueryRows(v interface{}, q string, args ...interface{}) error {
|
||||
return query(conn.db, func(rows *sql.Rows) error {
|
||||
@@ -56,6 +77,11 @@ func (conn *MockConn) QueryRows(v interface{}, q string, args ...interface{}) er
|
||||
}, q, args...)
|
||||
}
|
||||
|
||||
// QueryRowsCtx executes sql and returns query rows
|
||||
func (conn *MockConn) QueryRowsCtx(_ context.Context, v interface{}, query string, args ...interface{}) error {
|
||||
return conn.QueryRows(v, query, args...)
|
||||
}
|
||||
|
||||
// QueryRowsPartial executes sql and returns partial query rows
|
||||
func (conn *MockConn) QueryRowsPartial(v interface{}, q string, args ...interface{}) error {
|
||||
return query(conn.db, func(rows *sql.Rows) error {
|
||||
@@ -63,6 +89,11 @@ func (conn *MockConn) QueryRowsPartial(v interface{}, q string, args ...interfac
|
||||
}, q, args...)
|
||||
}
|
||||
|
||||
// QueryRowsPartialCtx executes sql and returns partial query rows
|
||||
func (conn *MockConn) QueryRowsPartialCtx(_ context.Context, v interface{}, query string, args ...interface{}) error {
|
||||
return conn.QueryRowsPartial(v, query, args...)
|
||||
}
|
||||
|
||||
// RawDB returns the underlying sql.DB.
|
||||
func (conn *MockConn) RawDB() (*sql.DB, error) {
|
||||
return conn.db, nil
|
||||
@@ -73,6 +104,11 @@ func (conn *MockConn) Transact(func(session sqlx.Session) error) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TransactCtx is the implemention of sqlx.SqlConn, nothing to do
|
||||
func (conn *MockConn) TransactCtx(ctx context.Context, fn func(context.Context, sqlx.Session) error) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s statement) Close() error {
|
||||
return s.stmt.Close()
|
||||
}
|
||||
@@ -81,26 +117,46 @@ func (s statement) Exec(args ...interface{}) (sql.Result, error) {
|
||||
return execStmt(s.stmt, args...)
|
||||
}
|
||||
|
||||
func (s statement) ExecCtx(_ context.Context, args ...interface{}) (sql.Result, error) {
|
||||
return s.Exec(args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRow(v interface{}, args ...interface{}) error {
|
||||
return queryStmt(s.stmt, func(rows *sql.Rows) error {
|
||||
return unmarshalRow(v, rows, true)
|
||||
}, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRowCtx(_ context.Context, v interface{}, args ...interface{}) error {
|
||||
return s.QueryRow(v, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRowPartial(v interface{}, args ...interface{}) error {
|
||||
return queryStmt(s.stmt, func(rows *sql.Rows) error {
|
||||
return unmarshalRow(v, rows, false)
|
||||
}, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRowPartialCtx(_ context.Context, v interface{}, args ...interface{}) error {
|
||||
return s.QueryRowPartial(v, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRows(v interface{}, args ...interface{}) error {
|
||||
return queryStmt(s.stmt, func(rows *sql.Rows) error {
|
||||
return unmarshalRows(v, rows, true)
|
||||
}, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRowsCtx(_ context.Context, v interface{}, args ...interface{}) error {
|
||||
return s.QueryRows(v, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRowsPartial(v interface{}, args ...interface{}) error {
|
||||
return queryStmt(s.stmt, func(rows *sql.Rows) error {
|
||||
return unmarshalRows(v, rows, false)
|
||||
}, args...)
|
||||
}
|
||||
|
||||
func (s statement) QueryRowsPartialCtx(_ context.Context, v interface{}, args ...interface{}) error {
|
||||
return s.QueryRowsPartial(v, args...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user