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: add documentation about Context methods #21244

Closed
carl-mastrangelo opened this issue Jul 31, 2017 · 3 comments
Closed

database/sql: add documentation about Context methods #21244

carl-mastrangelo opened this issue Jul 31, 2017 · 3 comments

Comments

@carl-mastrangelo
Copy link
Contributor

@carl-mastrangelo carl-mastrangelo commented Jul 31, 2017

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

Go 1.9

What did you expect to see?

Documentation about Context propagation for the new database context methods. For example, it isn't clear what happens in the following cases:

  • Does DB.BeginTx result in a Tx that has a context, or is the context only applied to the creation of the Tx?
  • Does DB.PrepareContext result in a Stmt that uses the passed in context? Phrased differently: does calling stmt.Exec() use the context passed to DB.PrepareContext ?
  • Similar to the above question, does Stmt.QueryContext use the context that was used to create it?
  • Does Tx.Prepare use the context that was used to create it? (

Reading the code clarifies that context is usually not passed around, but this isn't obvious from the docs. Furthermore, this does not make it clear if this is an implementation detail, or a part of the API.
Ideally, The database docs could include something along the lines of:

func (s *Stmt) Exec(args ... interface{}) (Result, error)

This is equivalent to

func (s *Stmt) ExecContext(context.Background(), args ...) (Result, error)
@odeke-em
Copy link
Member

@odeke-em odeke-em commented Aug 1, 2017

@carl-mastrangelo thanks for the issue report, I am going to mark this for Go1.10 since it seems too late for Go1.9
/cc @kardianos

@odeke-em odeke-em added this to the Go1.10 milestone Aug 1, 2017
@kardianos
Copy link
Contributor

@kardianos kardianos commented Aug 1, 2017

@carl-mastrangelo This would be for go1.10.

We may be able to clarify these points, but I'm fairly certain that the documentation does in fact state all of these facts. Are you able to suggest better wording to clarify these details?

@kardianos
Copy link
Contributor

@kardianos kardianos commented Sep 26, 2017

No clarification has been provided. Closing.

@kardianos kardianos closed this Sep 26, 2017
@golang golang locked and limited conversation to collaborators Sep 26, 2018
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
4 participants
You can’t perform that action at this time.