go-mysql-org / go-mysql

a powerful mysql toolset with Go
MIT License
4.52k stars 967 forks source link

converting argument $1 type: uint64 values with high bit set are not supported #886

Closed dvilaverde closed 1 month ago

dvilaverde commented 1 month ago

When attempting a query that requires an uint64, the driver fails with this error:

sql: converting argument $1 type: uint64 values with high bit set are not supported

Example:

conn, err := sql.Open("mysql", "root@127.0.0.1:3306/test")
defer conn.Close()

stmt, err := conn.Prepare("select a, b from tableA where uint64 = ?")
defer stmt.Close()

var val uint64 = math.MaxUint64
result, err := stmt.Query(val)

I don't see a way to use the https://pkg.go.dev/database/sql/driver#NamedValueChecker to allow for uint64 handling, or any custom Value types for that matter.

dvilaverde commented 1 month ago

I've added PR https://github.com/go-mysql-org/go-mysql/pull/887 to address this issue.