qustavo / sqlhooks

Attach hooks to any database/sql driver
MIT License
652 stars 44 forks source link

can't use transactions with sqlhooks #20

Closed minaevmike closed 3 years ago

minaevmike commented 6 years ago

I can't start transaction with non default isolation level because connection returned from sqlhooks.Conn wrapper doesn't implement driver.ConnBeginTx interface https://github.com/golang/go/blob/master/src/database/sql/ctxutil.go#L100

keegancsmith commented 6 years ago

@minaevmike see the implementation of sqlhooks. There are many optional interfaces which sqlhooks does not implement. Depending on how many upstream drivers implement ConnBeginTx sqlhooks can always support it, or do a more complicated implementation which first checks the underlying driver (unfortunately go doesn't make it easy to hook in with the driver pattern).

But yeah, contributions welcome.

qustavo commented 6 years ago

@minaevmike looks like you have a pretty good understanding of the solution, how long do you htink it could take to implement ConnBeginTx?

minaevmike commented 6 years ago

@gchaincl I don't think that it would take a lot of time. If you are not mind I can do it.

qustavo commented 6 years ago

@minaevmike please that would be great! as @keegancsmith contributions are welcome

qustavo commented 5 years ago

@minaevmike any progress on this one?

leeyongda commented 4 years ago

tx interface

func (conn *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
}