Only have a single Begin transaction method
This commit is contained in:
@@ -78,16 +78,9 @@ var ErrTxInFailure = errors.New("tx failed")
|
||||
// it is treated as ROLLBACK.
|
||||
var ErrTxCommitRollback = errors.New("commit unexpectedly resulted in rollback")
|
||||
|
||||
// Begin starts a transaction with the default transaction mode for the
|
||||
// current connection. To use a specific transaction mode see BeginEx.
|
||||
func (c *Conn) Begin() (*Tx, error) {
|
||||
return c.BeginEx(context.Background(), nil)
|
||||
}
|
||||
|
||||
// BeginEx starts a transaction with txOptions determining the transaction
|
||||
// mode. Unlike database/sql, the context only affects the begin command. i.e.
|
||||
// there is no auto-rollback on context cancelation.
|
||||
func (c *Conn) BeginEx(ctx context.Context, txOptions *TxOptions) (*Tx, error) {
|
||||
// BeginEx starts a transaction with txOptions determining the transaction mode. txOptions can be nil. Unlike
|
||||
// database/sql, the context only affects the begin command. i.e. there is no auto-rollback on context cancelation.
|
||||
func (c *Conn) Begin(ctx context.Context, txOptions *TxOptions) (*Tx, error) {
|
||||
_, err := c.Exec(ctx, txOptions.beginSQL())
|
||||
if err != nil {
|
||||
// begin should never fail unless there is an underlying connection issue or
|
||||
|
||||
Reference in New Issue
Block a user