diff --git a/sqlx.go b/sqlx.go index 8259a4f..aa433c6 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} diff --git a/sqlx_context.go b/sqlx_context.go index 32621d5..805244e 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 } @@ -353,6 +354,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) { @@ -405,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}