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

Method Stmtx

sqlx.go:474–487  ·  view source on GitHub ↗

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

(stmt interface{})

Source from the content-addressed store, hash-verified

472// Stmtx returns a version of the prepared statement which runs within a transaction. Provided
473// stmt can be either *sql.Stmt or *sqlx.Stmt.
474func (tx *Tx) Stmtx(stmt interface{}) *Stmt {
475 var s *sql.Stmt
476 switch v := stmt.(type) {
477 case Stmt:
478 s = v.Stmt
479 case *Stmt:
480 s = v.Stmt
481 case *sql.Stmt:
482 s = v
483 default:
484 panic(fmt.Sprintf("non-statement type %v passed to Stmtx", reflect.ValueOf(stmt).Type()))
485 }
486 return &Stmt{Stmt: tx.Stmt(s), Mapper: tx.Mapper}
487}
488
489// NamedStmt returns a version of the prepared statement which runs within a transaction.
490func (tx *Tx) NamedStmt(stmt *NamedStmt) *NamedStmt {

Callers 4

NamedStmtMethod · 0.95
TestUsageFunction · 0.80
TestUsageContextFunction · 0.80
TestConnFunction · 0.80

Calls

no outgoing calls

Tested by 3

TestUsageFunction · 0.64
TestUsageContextFunction · 0.64
TestConnFunction · 0.64