mailru / dbr

Additions to Go's database/sql for super fast performance and convenience. (fork of gocraft/dbr)
MIT License
178 stars 36 forks source link

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

Closed stevenctl closed 5 years ago

stevenctl commented 5 years ago

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 commented 5 years ago

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

DoubleDi commented 5 years ago

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