forked from upper/db
/
query_go18.go
72 lines (54 loc) · 1.94 KB
/
query_go18.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// +build go1.8
package compat
import (
"context"
"database/sql"
)
type PreparedExecer interface {
ExecContext(context.Context, ...interface{}) (sql.Result, error)
}
func PreparedExecContext(p PreparedExecer, ctx context.Context, args []interface{}) (sql.Result, error) {
return p.ExecContext(ctx, args...)
}
type Execer interface {
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
}
func ExecContext(p Execer, ctx context.Context, query string, args []interface{}) (sql.Result, error) {
return p.ExecContext(ctx, query, args...)
}
type PreparedQueryer interface {
QueryContext(context.Context, ...interface{}) (*sql.Rows, error)
}
func PreparedQueryContext(p PreparedQueryer, ctx context.Context, args []interface{}) (*sql.Rows, error) {
return p.QueryContext(ctx, args...)
}
type Queryer interface {
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
}
func QueryContext(p Queryer, ctx context.Context, query string, args []interface{}) (*sql.Rows, error) {
return p.QueryContext(ctx, query, args...)
}
type PreparedRowQueryer interface {
QueryRowContext(context.Context, ...interface{}) *sql.Row
}
func PreparedQueryRowContext(p PreparedRowQueryer, ctx context.Context, args []interface{}) *sql.Row {
return p.QueryRowContext(ctx, args...)
}
type RowQueryer interface {
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}
func QueryRowContext(p RowQueryer, ctx context.Context, query string, args []interface{}) *sql.Row {
return p.QueryRowContext(ctx, query, args...)
}
type Preparer interface {
PrepareContext(context.Context, string) (*sql.Stmt, error)
}
func PrepareContext(p Preparer, ctx context.Context, query string) (*sql.Stmt, error) {
return p.PrepareContext(ctx, query)
}
type TxStarter interface {
BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error)
}
func BeginTx(p TxStarter, ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) {
return p.BeginTx(ctx, opts)
}