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

allow passing sql.TxOptions when using Session.Begin #18

Merged
merged 2 commits into from
Aug 30, 2019

Conversation

stevenctl
Copy link
Contributor

Sometimes when using transactions I want to enforce behavior by setting read-only or isolation level. The current Session.Begin doesn't take any options and when it eventually calls BeginTx to get the underlying sql.Tx it just uses nil for the options.

This change is backward compatible and allows passing sql.TxOptions to BeginWithOpts while Begin retains it's original functionality.

Usage:

tx, err := sess.BeginWithOpts(&sql.TxOptions{
    Isolation: sql.LevelRepeatableRead,
})
defer tx.RollbackUnlessCommitted()

@stevenctl
Copy link
Contributor Author

Seems odd that the build is failing on SQLi stuff.. didn't touch much at all.

@DoubleDi
Copy link
Contributor

hello! Thanks for your PR.
We will fix our CI problems and merge you shortly

@DoubleDi DoubleDi merged commit 62d55b4 into mailru:master Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants