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
Implement database/sql/driver.DriverContext #900
base: master
Are you sure you want to change the base?
Conversation
9dc9624
to
3111ba2
Compare
LGTM! |
|
In order to fully instrument SQL operations (including new conns) by wrapping this driver with something like `github.com/luna-duclos/instrumentedsql`, this driver needs to implement `database/sql/driver.DriverContext`. Now it does.
3111ba2
to
8230504
Compare
The failure is:
So, the docs state that that's expected:
That test uses a value for This is a test that existed before. The question is: why didn't it fail before? Perhaps someone with more familiarity can shed some light on what's expected here. |
@dcormier Looks like this was introduced in 67337af. However, that was 7 years ago.. oof. Maybe @johto has some ideas. To me it looks like it's expected to fail, and that test verifies that it fails so I'm unsure the issue going on here. Actually looking more into this, it is supposed to fail, but it errors when it does fail. This looks like a bad test to me and needs some help. |
Adding additional background, so others can find this PR more easily in a search. This change is needed to avoid the default stdlib func (t dsnConnector) Connect(_ context.Context) (driver.Conn, error) {
return t.driver.Open(t.dsn)
} The TCP connection Lines 350 to 361 in 07d3f72
|
The test setup is using Lines 50 to 51 in f91d341
database/sql/sql.go:Open() https://github.com/golang/go/blob/8f4151ea67e1d498e0880f28d3fd803dc2c5448f/src/database/sql/sql.go#L770-L778 if driverCtx, ok := driveri.(driver.DriverContext); ok {
connector, err := driverCtx.OpenConnector(dataSourceName)
if err != nil {
return nil, err
}
return OpenDB(connector), nil
}
return OpenDB(dsnConnector{dsn: dataSourceName, driver: driveri}), nil When Lines 85 to 88 in f91d341
Possible solutions:
|
In order to fully instrument SQL operations (including new conns) by wrapping this driver with something like
github.com/luna-duclos/instrumentedsql
, this driver needs to implementdatabase/sql/driver.DriverContext
.Now it does.