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: confusing documentation for DefaultParameterConverter #11489

Closed
johto opened this issue Jun 30, 2015 · 6 comments
Closed

database/sql: confusing documentation for DefaultParameterConverter #11489

johto opened this issue Jun 30, 2015 · 6 comments

Comments

@johto
Copy link
Contributor

johto commented Jun 30, 2015

Hi,

In the documentation for DefaultParameterConvert we have this passage (emphasis mine):

DefaultParameterConverter returns the given value directly if IsValue(value).
Otherwise integer type are converted to int64, floats to float64, and strings to
[]byte
. Other types are an error.

However, if we look at the code, even all the way back to 1.0 IsValue has returned true for string. Thus, I don't see how a string could ever be converted to []byte.

Am I misreading this, or is the documentation incorrect?

@chakrit
Copy link

chakrit commented Jul 1, 2015

@johto I think that was meant to catch stuff like type MyStr string ?

@chakrit
Copy link

chakrit commented Jul 1, 2015

@chakrit
Copy link

chakrit commented Jul 1, 2015

I get []byte all the time whenever I have a special cased string type (such as those for enums or values that need special treatment like phone numbers or emails.)

@johto
Copy link
Contributor Author

johto commented Jul 1, 2015

Oh, so it's about the underlying type when the type returns false for IsValue(). Can we make it explicitly say that?

@ianlancetaylor
Copy link
Contributor

CC @bradfitz

@rsc rsc modified the milestones: Go1.6, Go1.5Maybe Jul 22, 2015
@rsc rsc changed the title database/sql: Confusing documentation for DefaultParameterConverter database/sql: confusing documentation for DefaultParameterConverter Nov 5, 2015
@gopherbot
Copy link

CL https://golang.org/cl/18520 mentions this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants