Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix commit error handling. #4

Merged
merged 1 commit into from
Nov 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}