Skip to content

Commit

Permalink
Merge pull request #38 from 2tvenom/master
Browse files Browse the repository at this point in the history
[-] fix permanent rollback in BeginTxFunc
  • Loading branch information
pashagolub authored Aug 17, 2021
2 parents 578eeda + 7fb208f commit 87e1f6a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pgxmock.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ func (c *pgxmock) BeginTxFunc(ctx context.Context, txOptions pgx.TxOptions, f fu
return err
}
defer func() {
if err == nil {
return
}
rollbackErr := tx.Rollback(ctx)
if !(rollbackErr == nil || errors.Is(rollbackErr, pgx.ErrTxClosed)) {
err = rollbackErr
Expand Down

0 comments on commit 87e1f6a

Please sign in to comment.