2
0

Only have a single Begin transaction method

This commit is contained in:
Jack Christensen
2019-04-24 13:35:27 -05:00
parent 1b8f0016e9
commit 2263521f70
9 changed files with 35 additions and 42 deletions
+3 -10
View File
@@ -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