sqlhooks icon indicating copy to clipboard operation
sqlhooks copied to clipboard

feat: support driver.DriverContext interface

Open conradludgate opened this issue 4 years ago • 3 comments

sql.Open internally makes use of the DriverContext interface, and if a Driver does not implement it, it creates a light wrapper1.

This DriverContext provides better context support as well as providing some useful error checking upfront. For instance, the mysql driver can check the DSN value before opening a connection to see if it's well formed. That way you get an error instantly instead of an error when making your first sql query

1: https://github.com/golang/go/blob/d0dd26a88c019d54f22463daae81e785f5867565/src/database/sql/sql.go#L832 https://github.com/golang/go/blob/d0dd26a88c019d54f22463daae81e785f5867565/src/database/sql/sql.go#L755-L766

conradludgate avatar Sep 23 '21 11:09 conradludgate

Hey @conradludgate thanks for doing this, it looks like a great contribution! Is there any way to test this?

qustavo avatar Sep 30 '21 06:09 qustavo

Hey @conradludgate thanks for doing this, it looks like a great contribution! Is there any way to test this?

Sure! I'll look into it later

conradludgate avatar Sep 30 '21 12:09 conradludgate