Conn.Begin and Conn.BeginTx return a Tx interface
This is necessary for the Conn.Begin method to signature as other methods that begin a transaction. This is technically a breaking change but practically is just a bug fix that is extremely unlikely to break any existing code.
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
# Unreleased
|
||||||
|
|
||||||
|
* Conn.Begin and Conn.BeginTx return a Tx interface instead of the internal dbTx struct. This is necessary for the Conn.Begin method to signature as other methods that begin a transaction. This is technically a breaking change but practically is just a bug fix that is extremely unlikely to break any existing code.
|
||||||
|
|
||||||
# 4.0.1 (September 19, 2019)
|
# 4.0.1 (September 19, 2019)
|
||||||
|
|
||||||
* Fix statement cache cleanup.
|
* Fix statement cache cleanup.
|
||||||
|
|||||||
@@ -67,13 +67,13 @@ var ErrTxCommitRollback = errors.New("commit unexpectedly resulted in rollback")
|
|||||||
|
|
||||||
// Begin starts a transaction. Unlike database/sql, the context only affects the begin command. i.e. there is no
|
// Begin starts a transaction. Unlike database/sql, the context only affects the begin command. i.e. there is no
|
||||||
// auto-rollback on context cancellation.
|
// auto-rollback on context cancellation.
|
||||||
func (c *Conn) Begin(ctx context.Context) (*dbTx, error) {
|
func (c *Conn) Begin(ctx context.Context) (Tx, error) {
|
||||||
return c.BeginTx(ctx, TxOptions{})
|
return c.BeginTx(ctx, TxOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// BeginTx starts a transaction with txOptions determining the transaction mode. Unlike database/sql, the context only
|
// BeginTx 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 cancellation.
|
// affects the begin command. i.e. there is no auto-rollback on context cancellation.
|
||||||
func (c *Conn) BeginTx(ctx context.Context, txOptions TxOptions) (*dbTx, error) {
|
func (c *Conn) BeginTx(ctx context.Context, txOptions TxOptions) (Tx, error) {
|
||||||
_, err := c.Exec(ctx, txOptions.beginSQL())
|
_, err := c.Exec(ctx, txOptions.beginSQL())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// begin should never fail unless there is an underlying connection issue or
|
// begin should never fail unless there is an underlying connection issue or
|
||||||
|
|||||||
Reference in New Issue
Block a user