2
0

Rows and Row are now interfaces

This commit is contained in:
Jack Christensen
2019-04-11 17:53:52 -05:00
parent 5ea8191003
commit 938ee9f434
11 changed files with 117 additions and 87 deletions
+4 -4
View File
@@ -172,20 +172,20 @@ func (tx *Tx) PrepareEx(ctx context.Context, name, sql string, opts *PrepareExOp
}
// Query delegates to the underlying *Conn
func (tx *Tx) Query(ctx context.Context, sql string, optionsAndArgs ...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 &connRows{closed: true, err: err}, err
}
return tx.conn.Query(ctx, sql, optionsAndArgs...)
}
// QueryRow delegates to the underlying *Conn
func (tx *Tx) QueryRow(ctx context.Context, sql string, optionsAndArgs ...interface{}) *Row {
func (tx *Tx) QueryRow(ctx context.Context, sql string, optionsAndArgs ...interface{}) Row {
rows, _ := tx.Query(ctx, sql, optionsAndArgs...)
return (*Row)(rows)
return (*connRow)(rows.(*connRows))
}
// CopyFrom delegates to the underlying *Conn