-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Connector Interface, take 3 #941
Conversation
The Coverall metrics have been reduced because we're no longer testing the deprecated |
I've been reading up on the issue some more, and I believe these changes are completely orthogonal to #903. This PR is backwards compatible with Go versions older than Go 1.10, and with or without this PR, the bug in #903 will take effect, so I don't see why that bug should block progression on the Connector interface. |
And it is very helpful if experienced contributors like you join discussion about |
I understand. I'll prepare a fix for #903 and submit it next week. Meanwhile, given that the issue is not related to this specific PR, I would appreciate if you could start reviewing these changes, since they are hardly new features but an important bug fix that users of the library are experiencing. Thanks. |
@methane: I know you're very busy but I would appreciate some help reviewing this PR, now that the I've pushed more tests to this PR to ensure we're covering all corner cases. Just to emphasize: besides being a new feature, implementing the This bug happens because without the We've been working around this by adding a Thanks again 🙇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Thank you for improving my implementation.
Uh, current Config is bad designed. I'm OK to having DialContext registry for a while. |
@methane: I think we still need Note that |
@methane: If you would prefer, I could implement a |
In addition, our driver should implement driver.DriverContext. |
@vmg I meant we can something like: cfg := mysql.ParseDSN(dsn)
cfg.SetDialer(YourDialer)
cn, err := mysql.NewConnector(cfg)
db, err := sql.OpenDB(cn) We need registries because we couldn't put objects in DSN. |
@methane: I see. That sounds good to me. I will implement it. What should I do with the existing registry? Should I remove the API? |
Question: what should happen when the user creates a DSN from a Config that has a dialer and uses the old API? Example: cfg := mysql.ParseDSN(dsn)
cfg.SetDialer(YourDialer)
db, err := sql.Open("mysql", cfg.FormatDSN()) Here |
When people want to use new feature (in this time, DialContext support), people should use But in this PR, I'm OK to add I don't want to add more registries. But |
That sounds good to me. In 2.0 we can remove |
That sounds good to me, but I think it is out of this pull request's scope. |
Description
Hi everyone! Here's another change from GitHub's internal fork of the MySQL driver. This is basically a rebase + refactoring of @shogo82148's original PR (#778) which has been stalled for almost a year!
This Pull Request brings the Go 1.0+ Connector interface to the MySQL driver, fixing several bugs, such as
:
in usernames DSNs, and most importantly for us, allowing new MySQL connections to obey acontext.Context
when dialing to the MySQL cluster.This PR updates the original with all the changes that have happened to master since then, and fixes several bugs and missing features, namely:
DialContext
registry has been implementedNewConnector
has been fixed so it's always equivalent to passing in a DSNConfig
structs has been improved so it no longer panics in some circumstancesWe've been running this branch internally for a while and it's been working great. I'm going to be actively checking in on this PR as much as needed to ensure it doesn't go stale. I would love to land it upstream because it's been a while since Go 1.10 has been released and I think the Driver should really support the new
Connector
interface.Let me know how can I make this easier to land!
cc @methane @shogo82148
Checklist