-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix bigint unsigned null column scan to err type int64 #1612
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
Changes from all commits
fb5a2a0
11f9287
4a5269c
fdd0987
6368cf3
9a48688
8006bf5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,8 @@ Alex Snast <alexsn at fb.com> | |
Alexey Palazhchenko <alexey.palazhchenko at gmail.com> | ||
Andrew Reid <andrew.reid at tixtrack.com> | ||
Animesh Ray <mail.rayanimesh at gmail.com> | ||
Arne Hormann <arnehormann at gmail.com> | ||
Ariel Mashraki <ariel at mashraki.co.il> | ||
Arne Hormann <arnehormann at gmail.com> | ||
Artur Melanchyk <[email protected]> | ||
Asta Xie <xiemengjun at gmail.com> | ||
B Lamarche <blam413 at gmail.com> | ||
|
@@ -62,6 +62,7 @@ Jeff Hodges <jeff at somethingsimilar.com> | |
Jeffrey Charles <jeffreycharles at gmail.com> | ||
Jennifer Purevsuren <jennifer at dolthub.com> | ||
Jerome Meyer <jxmeyer at gmail.com> | ||
Jiabin Zhang <jiabin.z at qq.com> | ||
Jiajia Zhong <zhong2plus at gmail.com> | ||
Jian Zhen <zhenjl at gmail.com> | ||
Joe Mann <contact at joemann.co.uk> | ||
|
@@ -81,10 +82,11 @@ Linh Tran Tuan <linhduonggnu at gmail.com> | |
Lion Yang <lion at aosc.xyz> | ||
Luca Looz <luca.looz92 at gmail.com> | ||
Lucas Liu <extrafliu at gmail.com> | ||
Lunny Xiao <xiaolunwen at gmail.com> | ||
Luke Scott <luke at webconnex.com> | ||
Lunny Xiao <xiaolunwen at gmail.com> | ||
Maciej Zimnoch <maciej.zimnoch at codilime.com> | ||
Michael Woolnough <michael.woolnough at gmail.com> | ||
Minh Quang <minhquang4334 at gmail.com> | ||
Nao Yokotsuka <yokotukanao at gmail.com> | ||
Nathanial Murphy <nathanial.murphy at gmail.com> | ||
Nicola Peduzzi <thenikso at gmail.com> | ||
|
@@ -95,7 +97,6 @@ Paul Bonser <misterpib at gmail.com> | |
Paulius Lozys <pauliuslozys at gmail.com> | ||
Peter Schultz <peter.schultz at classmarkets.com> | ||
Phil Porada <philporada at gmail.com> | ||
Minh Quang <minhquang4334 at gmail.com> | ||
Rebecca Chin <rchin at pivotal.io> | ||
Reed Allman <rdallman10 at gmail.com> | ||
Richard Wilkes <wilkes at me.com> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,6 +128,7 @@ var ( | |
scanTypeInt64 = reflect.TypeOf(int64(0)) | ||
scanTypeNullFloat = reflect.TypeOf(sql.NullFloat64{}) | ||
scanTypeNullInt = reflect.TypeOf(sql.NullInt64{}) | ||
scanTypeNullUint = reflect.TypeOf(sql.Null[uint64]{}) | ||
scanTypeNullTime = reflect.TypeOf(sql.NullTime{}) | ||
scanTypeUint8 = reflect.TypeOf(uint8(0)) | ||
scanTypeUint16 = reflect.TypeOf(uint16(0)) | ||
|
@@ -185,6 +186,9 @@ func (mf *mysqlField) scanType() reflect.Type { | |
} | ||
return scanTypeInt64 | ||
} | ||
if mf.flags&flagUnsigned != 0 { | ||
return scanTypeNullUint | ||
} | ||
Comment on lines
+189
to
+191
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Based on the test content examination, I can now provide a final response: Test coverage for unsigned bigint nulls is insufficient The codebase has tests for unsigned bigint (
🔗 Analysis chainVerify test coverage for unsigned bigint nulls. Let's ensure the changes are properly tested, especially for edge cases where uint64 values exceed int64 range. Let's examine the specific test content in driver_test.go since it appears in both searches. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for tests involving unsigned bigint columns
echo "Searching for tests with unsigned bigint columns..."
rg -l --type go "(?i)(unsigned.*bigint|uint64.*null)" *_test.go
# Search for existing null scanning tests
echo "Searching for null scanning tests..."
rg -l --type go "(?i)(nullint|nulluint|null.*scan)" *_test.go
Length of output: 755 Script: #!/bin/bash
# Check the content of driver_test.go for unsigned bigint and null scanning tests
echo "Examining driver_test.go for unsigned bigint and null scanning tests..."
rg -A 10 -B 2 "(?i)(unsigned.*bigint|uint64.*null|nullint|nulluint|null.*scan)" driver_test.go
Length of output: 11427 |
||
return scanTypeNullInt | ||
|
||
case fieldTypeFloat: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking change: sql.Null requires Go 1.22.
As mentioned in the PR discussion, Go 1.21 support hasn't been dropped yet. Using
sql.Null[uint64]
would break compatibility with Go 1.21 and earlier versions.Consider one of these alternatives: