Skip to content

Commit

Permalink
Fix commit error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
xaicron committed Nov 9, 2018
1 parent 99ac97e commit c05a6a2
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions tm/transaction_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ func Run(db SQL, f TxnFunc) error {
tx.Rollback()
return err
}
tx.Commit()
return nil
return tx.Commit()
}

// RunWithContext begins transaction with context.Conntext around TxnFunc.
Expand All @@ -97,8 +96,7 @@ func RunWithContext(ctx context.Context, opts *sql.TxOptions, db SQL, f TxnFunc)
tx.Rollback()
return err
}
tx.Commit()
return nil
return tx.Commit()
}

// Runx begins transaction around TxnxFunc.
Expand All @@ -113,8 +111,7 @@ func Runx(db SQLx, f TxnxFunc) error {
tx.Rollback()
return err
}
tx.Commit()
return nil
return tx.Commit()
}

// RunxWithContext begins transaction with context.Conntext around TxnxFunc.
Expand All @@ -129,6 +126,5 @@ func RunxWithContext(ctx context.Context, opts *sql.TxOptions, db SQLx, f TxnxFu
tx.Rollback()
return err
}
tx.Commit()
return nil
return tx.Commit()
}

0 comments on commit c05a6a2

Please sign in to comment.