You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.The text was updated successfully, but these errors were encountered: