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

feat: support driver.DriverContext interface #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

conradludgate
Copy link

@conradludgate conradludgate commented Sep 23, 2021

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 conradludgate changed the title feat: support driver.Connector interface feat: support driver.DriverContext interface Sep 23, 2021
@qustavo
Copy link
Owner

qustavo commented Sep 30, 2021

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

@conradludgate
Copy link
Author

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

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.

2 participants