From 046c3156329471cf568ea31f4129e0ba0cc888ff Mon Sep 17 00:00:00 2001 From: Maxim Korolyov Date: Thu, 6 Feb 2020 16:46:08 +0300 Subject: [PATCH] commit transaction of success --- pgx_adapter.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pgx_adapter.go b/pgx_adapter.go index 1578134..eb10de7 100644 --- a/pgx_adapter.go +++ b/pgx_adapter.go @@ -43,9 +43,14 @@ func (p *PgxAdapter) Transaction(ctx context.Context, f func(context.Context, Ex if rbErr != nil { err = errors.Wrapf(err, "failed to rollback failed transaction: %v", rbErr) } + return err } - return err + if err := tx.Commit(ctx); err != nil { + return errors.Wrap(err, "failed to commit transaction") + } + + return nil } func (p *PgxAdapter) Exec(ctx context.Context, sql string, args ...interface{}) (result RowsAffected, err error) {