MCPcopy
hub / github.com/jmoiron/sqlx / StmtxContext

Method StmtxContext

sqlx_context.go:282–295  ·  view source on GitHub ↗

StmtxContext returns a version of the prepared statement which runs within a transaction. Provided stmt can be either *sql.Stmt or *sqlx.Stmt.

(ctx context.Context, stmt interface{})

Source from the content-addressed store, hash-verified

280// StmtxContext returns a version of the prepared statement which runs within a
281// transaction. Provided stmt can be either *sql.Stmt or *sqlx.Stmt.
282func (tx *Tx) StmtxContext(ctx context.Context, stmt interface{}) *Stmt {
283 var s *sql.Stmt
284 switch v := stmt.(type) {
285 case Stmt:
286 s = v.Stmt
287 case *Stmt:
288 s = v.Stmt
289 case *sql.Stmt:
290 s = v
291 default:
292 panic(fmt.Sprintf("non-statement type %v passed to Stmtx", reflect.ValueOf(stmt).Type()))
293 }
294 return &Stmt{Stmt: tx.StmtContext(ctx, s), Mapper: tx.Mapper}
295}
296
297// NamedStmtContext returns a version of the prepared statement which runs
298// within a transaction.

Callers 1

NamedStmtContextMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected