mysql
mysql copied to clipboard
sql.ScanType Type error for nullable uint64
Issue description
Tell us what should happen and what happens instead
Example code
when field type bigint(20) unsigned null, this code will return scanTypeNullInt, it can't read uint64 data such 18446744073709551615.
https://github.com/go-sql-driver/mysql/blob/master/fields.go#L174
Error log
Configuration
Driver version (or git SHA):
1.7.1
Go version: run go version
in your console
1.18
Server version: E.g. MySQL 5.6, MariaDB 10.0.20
5.7
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
Debian 8.1
database/sql doesn't provide sql.NullUInt64. What other drivers do?
@methane https://github.com/ClickHouse/clickhouse-go/blob/aa43e908d734a38cea2dcfba4b898ddea9f35c66/lib/column/codegen/column.tpl#LL59C10-L59C10
like clickhouse, it will return big.Int when field greater than int64
I don't want to use Big. NullUInt64 is better, but I hope database/sql provide it.
https://github.com/golang/go/issues/47953
golang/go#47953 was rejected and closed. Now I proposed https://github.com/golang/go/issues/60370
sql.Null[T]
will be in Go 1.22.
I won't add it in this driver.
Please copy&paste the sql.Null[T]
from Go 1.22 into your application until you can use Go 1.22. ("A little copying is better than a little dependency.")