From 502e7d66b8b6e8c006a7702d71d8a881724a1593 Mon Sep 17 00:00:00 2001 From: Camilo Aguilar Date: Sat, 17 Jun 2017 17:59:31 -0400 Subject: [PATCH 1/2] Add missing PreparexContext function --- sqlx_context.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sqlx_context.go b/sqlx_context.go index 0b171451..8a7aed1e 100644 --- a/sqlx_context.go +++ b/sqlx_context.go @@ -237,6 +237,14 @@ func (tx *Tx) NamedStmtContext(ctx context.Context, stmt *NamedStmt) *NamedStmt } } +// PreparexContext returns an sqlx.Stmt instead of a sql.Stmt. +// +// The provided context is used for the preparation of the statement, not for +// the execution of the statement. +func (tx *Tx) PreparexContext(ctx context.Context, query string) (*Stmt, error) { + return PreparexContext(ctx, tx, query) +} + // MustExecContext runs MustExecContext within a transaction. // Any placeholder parameters are replaced with supplied args. func (tx *Tx) MustExecContext(ctx context.Context, query string, args ...interface{}) sql.Result { From 9afb36a500a4a1f78b7ad917519a04bcbf239aea Mon Sep 17 00:00:00 2001 From: Camilo Aguilar Date: Sun, 18 Jun 2017 10:34:05 -0400 Subject: [PATCH 2/2] Add missing tx.PrepareNamedContext function --- sqlx_context.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sqlx_context.go b/sqlx_context.go index 8a7aed1e..d58ff337 100644 --- a/sqlx_context.go +++ b/sqlx_context.go @@ -245,6 +245,11 @@ func (tx *Tx) PreparexContext(ctx context.Context, query string) (*Stmt, error) return PreparexContext(ctx, tx, query) } +// PrepareNamedContext returns an sqlx.NamedStmt +func (tx *Tx) PrepareNamedContext(ctx context.Context, query string) (*NamedStmt, error) { + return prepareNamedContext(ctx, tx, query) +} + // MustExecContext runs MustExecContext within a transaction. // Any placeholder parameters are replaced with supplied args. func (tx *Tx) MustExecContext(ctx context.Context, query string, args ...interface{}) sql.Result {