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
contrib/sql/driver: use the connector provided by the sql driver if possible #1502
Conversation
@ajgajg1134 Sorry to get my nose in here but any chance we could have this one be included in v1.43.0 instead of 1.44.0? This would be really helpful in unblocking more internal users of sql tracing. |
…ossible Currently, when the sql tracer opens a new database with the Open(...) function, it uses a default dsnConnector. However, if the driver implements the `DriverContext` interface, the one provided by the `OpenConnector(...)` method on the driver should be used instead. And the documentation on the sql library says that the `DriverContext` should be implemented : > The driver interface has evolved over time. Drivers should implement Connector and DriverContext interfaces. (from: https://pkg.go.dev/database/sql/driver@go1.19.2) This commit uses the connector provided by the sql driver if it implements the `DriverContext` and follows the same logic as the std lib sql library: https://github.com/golang/go/blob/515e3de2999b23da28e6d15ac485bfdd299ec83a/src/database/sql/sql.go#L821-L829
a0bbe3f
to
2def902
Compare
@Julio-Guerra do you think there's still time to get this change into v1.43? It is possible to do, but since we've already created the release branch for v1.43 you'll need to get this change to both |
Yes, I'll try merging it into the release branch and see on Monday if everything is okay with it. Feel free to merge that one to |
It looks like this change breaks the sql tests in the contrib packages? Let me know if you'd like an extra pair of 👀 to take a look at the test failures |
9e2b3d0
to
7f5bd7c
Compare
Thanks for being open to including this on the 1.43.0 branch, @Julio-Guerra ! Much appreciated 🙇 |
v1.43.0-rc.4 is out and includes that fix. |
Currently, when the sql tracer opens a new database with the Open(...) function, it uses a default dsnConnector. However, if the driver implements the
DriverContext
interface, the one provided by theOpenConnector(...)
method on the driver should be used instead. And the documentation on the sql library says that theDriverContext
should be implemented :(from: https://pkg.go.dev/database/sql/driver@go1.19.2)
This commit uses the connector provided by the sql driver if it implements the
DriverContext
and follows the same logic as the std lib sql library: https://github.com/golang/go/blob/515e3de2999b23da28e6d15ac485bfdd299ec83a/src/database/sql/sql.go#L821-L829