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

database/sql: Support QueryerContext without Queryer or Prepare() #22980

Closed
tejasmanohar opened this issue Dec 4, 2017 · 1 comment
Closed

database/sql: Support QueryerContext without Queryer or Prepare() #22980

tejasmanohar opened this issue Dec 4, 2017 · 1 comment

Comments

@tejasmanohar
Copy link

@tejasmanohar tejasmanohar commented Dec 4, 2017

What version of Go are you using (go version)?

go1.9

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Irrelevant, reproducible on playground.

What did you do?

I'm implementing a database/sql.Driver with the new context API for a database that doesn't support prepared statements.

In my first attempt (playground) where I only implemented the QueryerContext interface, database/sql called Prepare() and my driver panic'd since it was unsupported. I expected QueryerContext to be sufficient to call database/sql.DB.Query() without Prepare() since the docs say

If a Conn does not implement QueryerContext, the sql package's DB.Query will first prepare a query, execute the statement, and then close the statement.

After more investigation, it seems like you need to implement the (deprecated) Queryer interface, too, in order to skip prepared statements even though its methods are not called. See my successful example (playground). This was unexpected since the docs say

Deprecated: Drivers should implement QueryerContext instead (or additionally).

Is this expected? Am I misunderstanding the docs? Happy to submit a patch if it's a bug :-)

@kardianos
Copy link
Contributor

@kardianos kardianos commented Dec 18, 2017

This is fixed for go1.10. Please test on the go1.10 beta.

@kardianos kardianos closed this Mar 5, 2018
@golang golang locked and limited conversation to collaborators Mar 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.