Remove Ex versions of Query and QueryRow
Always require context and prepend options to arguments if necessary.
This commit is contained in:
@@ -185,30 +185,19 @@ func (tx *Tx) PrepareEx(ctx context.Context, name, sql string, opts *PrepareExOp
|
||||
}
|
||||
|
||||
// Query delegates to the underlying *Conn
|
||||
func (tx *Tx) Query(sql string, args ...interface{}) (*Rows, error) {
|
||||
return tx.QueryEx(context.Background(), sql, nil, args...)
|
||||
}
|
||||
|
||||
// QueryEx delegates to the underlying *Conn
|
||||
func (tx *Tx) QueryEx(ctx context.Context, sql string, options *QueryExOptions, args ...interface{}) (*Rows, error) {
|
||||
func (tx *Tx) Query(ctx context.Context, sql string, optionsAndArgs ...interface{}) (*Rows, error) {
|
||||
if tx.status != TxStatusInProgress {
|
||||
// Because checking for errors can be deferred to the *Rows, build one with the error
|
||||
err := ErrTxClosed
|
||||
return &Rows{closed: true, err: err}, err
|
||||
}
|
||||
|
||||
return tx.conn.QueryEx(ctx, sql, options, args...)
|
||||
return tx.conn.Query(ctx, sql, optionsAndArgs...)
|
||||
}
|
||||
|
||||
// QueryRow delegates to the underlying *Conn
|
||||
func (tx *Tx) QueryRow(sql string, args ...interface{}) *Row {
|
||||
rows, _ := tx.Query(sql, args...)
|
||||
return (*Row)(rows)
|
||||
}
|
||||
|
||||
// QueryRowEx delegates to the underlying *Conn
|
||||
func (tx *Tx) QueryRowEx(ctx context.Context, sql string, options *QueryExOptions, args ...interface{}) *Row {
|
||||
rows, _ := tx.QueryEx(ctx, sql, options, args...)
|
||||
func (tx *Tx) QueryRow(ctx context.Context, sql string, optionsAndArgs ...interface{}) *Row {
|
||||
rows, _ := tx.Query(ctx, sql, optionsAndArgs...)
|
||||
return (*Row)(rows)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user