From fb5a2a0adb17b65a2793e706c20278b74c0c155a Mon Sep 17 00:00:00 2001 From: elonnzhang Date: Fri, 26 Jul 2024 19:29:52 +0800 Subject: [PATCH 1/4] fix bigint unsigned null cloumn scan to err type int64 --- fields.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fields.go b/fields.go index be5cd809..7e4134ca 100644 --- a/fields.go +++ b/fields.go @@ -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 + } return scanTypeNullInt case fieldTypeFloat: From 11f9287323f7249519405560407d4f5cd2b10bc0 Mon Sep 17 00:00:00 2001 From: elonnzhang Date: Fri, 26 Jul 2024 20:11:55 +0800 Subject: [PATCH 2/4] add auth --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index bab66a3b..97b4a9f1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -120,6 +120,7 @@ Zhang Xiang Zhenye Xie Zhixin Wen Ziheng Lyu +Jiabin Zhang # Organizations From 4a5269cd00707f494088f1b368fd293cb8fb4d49 Mon Sep 17 00:00:00 2001 From: elonnzhang Date: Mon, 29 Jul 2024 21:59:12 +0800 Subject: [PATCH 3/4] use type sql.NullString support uint64, avoid out of range int64, because sql.Null introduce in go1.22 --- fields.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fields.go b/fields.go index 7e4134ca..bd8757bd 100644 --- a/fields.go +++ b/fields.go @@ -128,7 +128,7 @@ var ( scanTypeInt64 = reflect.TypeOf(int64(0)) scanTypeNullFloat = reflect.TypeOf(sql.NullFloat64{}) scanTypeNullInt = reflect.TypeOf(sql.NullInt64{}) - scanTypeNullUInt = reflect.TypeOf(sql.Null[uint64]{}) + scanTypeNullUint = reflect.TypeOf(sql.NullString{}) // reflect.TypeOf(sql.Null[uint64]{}) // support in go 1.22 scanTypeNullTime = reflect.TypeOf(sql.NullTime{}) scanTypeUint8 = reflect.TypeOf(uint8(0)) scanTypeUint16 = reflect.TypeOf(uint16(0)) @@ -187,7 +187,7 @@ func (mf *mysqlField) scanType() reflect.Type { return scanTypeInt64 } if mf.flags&flagUnsigned != 0 { - return scanTypeNullUInt + return scanTypeNullUint } return scanTypeNullInt From 6368cf39ae87cbf3e78691905febe5054ce2923e Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Mon, 11 Nov 2024 11:31:04 +0900 Subject: [PATCH 4/4] use sql.Null --- fields.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fields.go b/fields.go index bd8757bd..25a16628 100644 --- a/fields.go +++ b/fields.go @@ -128,7 +128,7 @@ var ( scanTypeInt64 = reflect.TypeOf(int64(0)) scanTypeNullFloat = reflect.TypeOf(sql.NullFloat64{}) scanTypeNullInt = reflect.TypeOf(sql.NullInt64{}) - scanTypeNullUint = reflect.TypeOf(sql.NullString{}) // reflect.TypeOf(sql.Null[uint64]{}) // support in go 1.22 + scanTypeNullUint = reflect.TypeOf(sql.Null[uint64]{}) scanTypeNullTime = reflect.TypeOf(sql.NullTime{}) scanTypeUint8 = reflect.TypeOf(uint8(0)) scanTypeUint16 = reflect.TypeOf(uint16(0))