diff --git a/CHANGELOG.md b/CHANGELOG.md index 54c66b89..d17b01bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) * Fix statement cache cleanup. diff --git a/tx.go b/tx.go index 600983d4..5822e9f5 100644 --- a/tx.go +++ b/tx.go @@ -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 // 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{}) } // 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. -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()) if err != nil { // begin should never fail unless there is an underlying connection issue or