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

database/gdb: The columnValueToLocalValue() and CheckLocalTypeForField() functions determine that the UNSIGNED INT unsigned type is a string type when converting it. #4067

Open
ANG-LD opened this issue Dec 20, 2024 · 0 comments
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@ANG-LD
Copy link

ANG-LD commented Dec 20, 2024

Go version

go1.22

GoFrame version

2.8.3

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

func (c *Core) columnValueToLocalValue(ctx context.Context, value interface{}, columnType *sql.ColumnType) (interface{}, error) {
	var scanType = columnType.ScanType()
	if scanType != nil {
		// Common basic builtin types.
		switch scanType.Kind() {
		case
			reflect.Bool,
			reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
			reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
			reflect.Float32, reflect.Float64:
			return gconv.Convert(
				gconv.String(value),
				columnType.ScanType().String(),
			), nil
		default:
		}
	}
	// Other complex types, especially custom types.
	return c.db.ConvertValueForLocal(ctx, columnType.DatabaseTypeName(), value)
}

主键UNSIGNED类型能进入gconv.Convert转化成int类型,非主键的UNSIGNED INT类型进入ConvertValueForLocal分支,但该函数转化成了string类型

What did you see happen?

查询主键和非主键的UNSIGNED INT,打印结构不一致

What did you expect to see?

查询主键和非主键的UNSIGNED INT,打印结构不一致

@ANG-LD ANG-LD added the bug It is confirmed a bug, but don't worry, we'll handle it. label Dec 20, 2024
@Issues-translate-bot Issues-translate-bot changed the title database/gdb: columnValueToLocalValue()和CheckLocalTypeForField()函数在转化UNSIGNED INT无符号类型时判断为字符串类型 database/gdb: The columnValueToLocalValue() and CheckLocalTypeForField() functions determine that the UNSIGNED INT unsigned type is a string type when converting it. Dec 20, 2024
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.
Projects
None yet
Development

No branches or pull requests

1 participant