Skip to content
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

数据库 unsigned 类型识别失败,无符号类型全部识别成了有符号类型 #2356

Closed
xt-inking opened this issue Dec 13, 2022 · 3 comments
Assignees
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. done This issue is done, which may be release in next version.

Comments

@xt-inking
Copy link

xt-inking commented Dec 13, 2022

1. What version of Go and system type/arch are you using?

go version go1.19.4 linux/amd64

2. What version of GoFrame are you using?

v2.2.5

3. Can this issue be re-produced with the latest release?

Yes.

4. What did you do?

CREATE TABLE `demo` (
	`id` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
	PRIMARY KEY (`id`) USING BTREE
)
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
;
INSERT INTO `demo` (`id`) VALUES (18446744073709551615);
package main

import (
	"github.com/gogf/gf/v2/frame/g"

	_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
)

func main() {
	r, e := g.DB().Model("demo").One()
	if e != nil {
		panic(e)
	}
	g.DumpWithType(r["id"].Val())
}

5. What did you expect to see?

uint64(18446744073709551615)
or
uint(18446744073709551615)

6. What did you see instead?

int64(-9223372036854775808)

@xt-inking
Copy link
Author

查源码发现框架 *gdb.Core 的 ConvertValueForLocal 方法的 fieldType 参数依照 float(5,2), unsigned double(5,2), decimal(10,2), char(45), varchar(100), etc. 格式进行处理,但该参数的值来源于 *sql.ColumnType 类型的 DatabaseTypeName 方法,此方法只会返回 "VARCHAR", "TEXT", "NVARCHAR", "DECIMAL", "BOOL", "INT", and "BIGINT" 等格式的值。

@gqcn gqcn added the bug It is confirmed a bug, but don't worry, we'll handle it. label Feb 6, 2023
@gqcn
Copy link
Member

gqcn commented Feb 6, 2023

@xt-inking 感谢反馈,我先打上标签,后续跟进查看一下。

@gqcn gqcn self-assigned this Feb 7, 2023
gqcn added a commit that referenced this issue Feb 7, 2023
@gqcn
Copy link
Member

gqcn commented Feb 7, 2023

#2428

@gqcn gqcn added the done This issue is done, which may be release in next version. label Feb 7, 2023
@gqcn gqcn closed this as completed Feb 7, 2023
gqcn added a commit that referenced this issue Feb 7, 2023
gqcn added a commit that referenced this issue Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. done This issue is done, which may be release in next version.
Projects
None yet
Development

No branches or pull requests

2 participants