Skip to content

sql.ScanType Type error for nullable uint64 #1433

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

Closed
quanqqqqq opened this issue May 22, 2023 · 7 comments
Closed

sql.ScanType Type error for nullable uint64 #1433

quanqqqqq opened this issue May 22, 2023 · 7 comments

Comments

@quanqqqqq
Copy link

quanqqqqq commented May 22, 2023

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
image

Error log

image

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

@methane
Copy link
Member

methane commented May 22, 2023

database/sql doesn't provide sql.NullUInt64. What other drivers do?

@quanqqqqq
Copy link
Author

quanqqqqq commented May 22, 2023

@methane
Copy link
Member

methane commented May 23, 2023

I don't want to use Big.
NullUInt64 is better, but I hope database/sql provide it.

@methane methane changed the title [Bug] sql.ScanType Type error sql.ScanType Type error May 23, 2023
@methane
Copy link
Member

methane commented May 23, 2023

golang/go#47953

@methane
Copy link
Member

methane commented May 23, 2023

golang/go#47953 was rejected and closed.
Now I proposed golang/go#60370

@methane methane changed the title sql.ScanType Type error sql.ScanType Type error for nullable uint64 Jun 16, 2023
@dolmen
Copy link
Contributor

dolmen commented Oct 17, 2023

sql.Null[T] will be in Go 1.22.

@methane
Copy link
Member

methane commented Oct 19, 2023

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.")

@methane methane closed this as completed Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants