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

float64 are not parsed properly when query is run with placeholders #433

Closed
pib opened this issue Mar 3, 2016 · 0 comments
Closed

float64 are not parsed properly when query is run with placeholders #433

pib opened this issue Mar 3, 2016 · 0 comments
Labels
Milestone

Comments

@pib
Copy link
Contributor

pib commented Mar 3, 2016

Here's a gist with minimal Go code and SQL demonstrating the issue: https://gist.github.com/pib/f8c9a4e153e6d226d2ee

When the data comes back in the no-placeholder version (which from #215, #211, #86 I see is different because it is run in text mode), the float value (which is a 32-bit float in MySQL) is parsed properly into a float64.

When the data comes back in the placeholder version, it is treated the same way as if strconv.ParseFloat(val, 32) was called demonstrated here: https://play.golang.org/p/HqWFhvYD31.

Switching to a float32 fixed the issue in my case, but this was a very confusing situation and it took a while to realize that it was caused by differences in behavior between queries with and without placeholders.

It seems like readRow (here: https://github.com/go-sql-driver/mysql/blob/master/packets.go#L1151) should be putting MySQL float types into a float32 instead of a float64 to prevent this situation.

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

No branches or pull requests

2 participants