generator #77
3
stmt.go
3
stmt.go
@ -75,8 +75,7 @@ func (w *wrapperStmt) Exec(args []driver.Value) (driver.Result, error) {
|
|||||||
}
|
}
|
||||||
labels := []string{labelMethod, "Exec"}
|
labels := []string{labelMethod, "Exec"}
|
||||||
ts := time.Now()
|
ts := time.Now()
|
||||||
// nolint:staticcheck
|
res, err := w.stmt.Exec(args) // nolint:staticcheck
|
||||||
res, err := w.stmt.Exec(args)
|
|
||||||
td := time.Since(ts)
|
td := time.Since(ts)
|
||||||
te := td.Seconds()
|
te := td.Seconds()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
112
wrap.go
112
wrap.go
@ -11,118 +11,6 @@ func wrapDriver(d driver.Driver, opts Options) driver.Driver {
|
|||||||
return struct{ driver.Driver }{&wrapperDriver{driver: d, opts: opts}}
|
return struct{ driver.Driver }{&wrapperDriver{driver: d, opts: opts}}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func wrapStmt(stmt driver.Stmt, query string, opts Options) driver.Stmt {
|
|
||||||
var (
|
|
||||||
_, hasExeCtx = stmt.(driver.StmtExecContext)
|
|
||||||
_, hasQryCtx = stmt.(driver.StmtQueryContext)
|
|
||||||
wc, hasColConv = stmt.(driver.ColumnConverter) //nolint:staticcheck
|
|
||||||
wn, hasNamValChk = stmt.(driver.NamedValueChecker)
|
|
||||||
)
|
|
||||||
|
|
||||||
ws := &wrapperStmt{stmt: stmt, query: query, opts: opts}
|
|
||||||
switch {
|
|
||||||
case !hasExeCtx && !hasQryCtx && !hasColConv && !hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
}{ws}
|
|
||||||
case !hasExeCtx && hasQryCtx && !hasColConv && !hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.StmtQueryContext
|
|
||||||
}{ws, ws}
|
|
||||||
case hasExeCtx && !hasQryCtx && !hasColConv && !hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.StmtExecContext
|
|
||||||
}{ws, ws}
|
|
||||||
case hasExeCtx && hasQryCtx && !hasColConv && !hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.StmtExecContext
|
|
||||||
driver.StmtQueryContext
|
|
||||||
}{ws, ws, ws}
|
|
||||||
case !hasExeCtx && !hasQryCtx && hasColConv && !hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.ColumnConverter
|
|
||||||
}{ws, wc}
|
|
||||||
case !hasExeCtx && hasQryCtx && hasColConv && !hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.StmtQueryContext
|
|
||||||
driver.ColumnConverter
|
|
||||||
}{ws, ws, wc}
|
|
||||||
case hasExeCtx && !hasQryCtx && hasColConv && !hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.StmtExecContext
|
|
||||||
driver.ColumnConverter
|
|
||||||
}{ws, ws, wc}
|
|
||||||
case hasExeCtx && hasQryCtx && hasColConv && !hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.StmtExecContext
|
|
||||||
driver.StmtQueryContext
|
|
||||||
driver.ColumnConverter
|
|
||||||
}{ws, ws, ws, wc}
|
|
||||||
case !hasExeCtx && !hasQryCtx && !hasColConv && hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.NamedValueChecker
|
|
||||||
}{ws, wn}
|
|
||||||
case !hasExeCtx && hasQryCtx && !hasColConv && hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.StmtQueryContext
|
|
||||||
driver.NamedValueChecker
|
|
||||||
}{ws, ws, wn}
|
|
||||||
case hasExeCtx && !hasQryCtx && !hasColConv && hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.StmtExecContext
|
|
||||||
driver.NamedValueChecker
|
|
||||||
}{ws, ws, wn}
|
|
||||||
case hasExeCtx && hasQryCtx && !hasColConv && hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.StmtExecContext
|
|
||||||
driver.StmtQueryContext
|
|
||||||
driver.NamedValueChecker
|
|
||||||
}{ws, ws, ws, wn}
|
|
||||||
case !hasExeCtx && !hasQryCtx && hasColConv && hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.ColumnConverter
|
|
||||||
driver.NamedValueChecker
|
|
||||||
}{ws, wc, wn}
|
|
||||||
case !hasExeCtx && hasQryCtx && hasColConv && hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.StmtQueryContext
|
|
||||||
driver.ColumnConverter
|
|
||||||
driver.NamedValueChecker
|
|
||||||
}{ws, ws, wc, wn}
|
|
||||||
case hasExeCtx && !hasQryCtx && hasColConv && hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.StmtExecContext
|
|
||||||
driver.ColumnConverter
|
|
||||||
driver.NamedValueChecker
|
|
||||||
}{ws, ws, wc, wn}
|
|
||||||
case hasExeCtx && hasQryCtx && hasColConv && hasNamValChk:
|
|
||||||
return struct {
|
|
||||||
driver.Stmt
|
|
||||||
driver.StmtExecContext
|
|
||||||
driver.StmtQueryContext
|
|
||||||
driver.ColumnConverter
|
|
||||||
driver.NamedValueChecker
|
|
||||||
}{ws, ws, ws, wc, wn}
|
|
||||||
}
|
|
||||||
panic("unreachable")
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// WrapConn allows an existing driver.Conn to be wrapped.
|
// WrapConn allows an existing driver.Conn to be wrapped.
|
||||||
func WrapConn(c driver.Conn, opts ...Option) driver.Conn {
|
func WrapConn(c driver.Conn, opts ...Option) driver.Conn {
|
||||||
return wrapConn(c, NewOptions(opts...))
|
return wrapConn(c, NewOptions(opts...))
|
||||||
|
Loading…
Reference in New Issue
Block a user