-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Custom int type not working with interpolateParams=true #915
Comments
As a work around this works since it uses the built in database/sql convertAssign function to convert []uint8 (i.e a byte slice) to an integer. However the Scanner interface documentation states that we can expect int64 values from the driver and I am wondering why it is different from interpolateParams set to true vs false.
|
Digging in a bit further this seems to be the result of an interpolated query using textRows and a prepared statement uses binaryRows. It seems that the column definitions are given in the resultSet, but then aren't actually used to type the results so everything being sent from an interpolated query is always a byte slice. :( |
Duplicate of #861.
https://golang.org/pkg/database/sql/#Scanner says:
So you should expect one of them, not only int64.
Performance reason. We choose most efficient type.
It's not work around. It's by design. |
I guess the problem is that I had to spend a lot of time digging in deep to figuring out that the two protocols are fundamentally different. Maybe some documentation would be in order since this is the second time it has come up? |
There is: https://golang.org/pkg/database/sql/#Scanner says:
No need to understand underlaying protocol. You should expect these types, as document says. |
Issue description
My SQL enviroment does not support Prepared statements so I turned on interpolateParams=True and my custom type's Scan function gets a
[]uint8
instead of anint64
.Example code
Configuration
Driver version (or git SHA): lastest
Go version:
go version go1.11.2 linux/amd64
Server version: MySQL 5.6.35
Server OS: E.g. Centos 7
The text was updated successfully, but these errors were encountered: