From 692dbaed1de2e87ee8f24a17bd6b4c362cbd8019 Mon Sep 17 00:00:00 2001 From: Jon Senchyna Date: Fri, 30 Aug 2024 21:53:35 -0400 Subject: [PATCH 1/3] feat: add missing tx.NamedQueryContext method --- sqlx_context.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sqlx_context.go b/sqlx_context.go index 32621d56..ff576973 100644 --- a/sqlx_context.go +++ b/sqlx_context.go @@ -353,6 +353,12 @@ func (tx *Tx) QueryRowxContext(ctx context.Context, query string, args ...interf return &Row{rows: rows, err: err, unsafe: tx.unsafe, Mapper: tx.Mapper} } +// NamedQueryContext using this DB. +// Any named placeholder parameters are replaced with fields from arg. +func (tx *Tx) NamedQueryContext(ctx context.Context, query string, arg interface{}) (*Rows, error) { + return NamedQueryContext(ctx, tx, query, arg) +} + // NamedExecContext using this Tx. // Any named placeholder parameters are replaced with fields from arg. func (tx *Tx) NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error) { From 1041a75112402058e848ae78e92146fb027d8ce8 Mon Sep 17 00:00:00 2001 From: Jon Senchyna Date: Fri, 30 Aug 2024 22:19:19 -0400 Subject: [PATCH 2/3] Add missing QueryRow to Querer --- sqlx.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sqlx.go b/sqlx.go index 8259a4fe..aa433c64 100644 --- a/sqlx.go +++ b/sqlx.go @@ -77,6 +77,7 @@ type ColScanner interface { type Queryer interface { Query(query string, args ...interface{}) (*sql.Rows, error) Queryx(query string, args ...interface{}) (*Rows, error) + QueryRow(query string, args ...interface{}) *sql.Row QueryRowx(query string, args ...interface{}) *Row } @@ -563,6 +564,10 @@ func (q *qStmt) Queryx(query string, args ...interface{}) (*Rows, error) { return &Rows{Rows: r, unsafe: q.Stmt.unsafe, Mapper: q.Stmt.Mapper}, err } +func (q *qStmt) QueryRow(query string, args ...interface{}) *sql.Row { + return q.Stmt.QueryRow(args...) +} + func (q *qStmt) QueryRowx(query string, args ...interface{}) *Row { rows, err := q.Stmt.Query(args...) return &Row{rows: rows, err: err, unsafe: q.Stmt.unsafe, Mapper: q.Stmt.Mapper} From d7de12833ee0a64e48edc397febf02509735567c Mon Sep 17 00:00:00 2001 From: Jon Senchyna Date: Fri, 30 Aug 2024 22:19:30 -0400 Subject: [PATCH 3/3] Add missing QueryRowContext to QuererContext --- sqlx_context.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sqlx_context.go b/sqlx_context.go index ff576973..805244e0 100644 --- a/sqlx_context.go +++ b/sqlx_context.go @@ -26,6 +26,7 @@ func ConnectContext(ctx context.Context, driverName, dataSourceName string) (*DB type QueryerContext interface { QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryxContext(ctx context.Context, query string, args ...interface{}) (*Rows, error) + QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row QueryRowxContext(ctx context.Context, query string, args ...interface{}) *Row } @@ -411,6 +412,10 @@ func (q *qStmt) QueryxContext(ctx context.Context, query string, args ...interfa return &Rows{Rows: r, unsafe: q.Stmt.unsafe, Mapper: q.Stmt.Mapper}, err } +func (q *Stmt) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row { + return q.Stmt.QueryRowContext(ctx, args...) +} + func (q *qStmt) QueryRowxContext(ctx context.Context, query string, args ...interface{}) *Row { rows, err := q.Stmt.QueryContext(ctx, args...) return &Row{rows: rows, err: err, unsafe: q.Stmt.unsafe, Mapper: q.Stmt.Mapper}