db icon indicating copy to clipboard operation
db copied to clipboard

upper/v4: consider exposing SetTxOptions

Open mfridman opened this issue 5 years ago • 1 comments

One property we relied in the forked pressly bond was the ability to set the sql.TxOptions. This has saved us a few times where we explicitly wanted to treat the entire session as read-only.

I see the only place this can be set explicitly is through the upper API is:

TxContext(ctx context.Context, fn func(sess Session) error, opts *sql.TxOptions) error

But, it'd be useful if the SetTxOptions were exposed publicly, something like:

sess, err = postgresql.Open(conn)
if err != nil {
  // ..
}

sess.SetTxOptions(...)

This would apply to the sqladapter.session but be treated as a nop for the other impl.

Alternatively, it could also reside on the Settings interface .. not sure though.

mfridman avatar Sep 16 '20 02:09 mfridman

sounds like a good idea. can you guys submit a PR?

pkieltyka avatar Sep 23 '20 12:09 pkieltyka