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

The type of MySQL query results differs from the actual ones #4088

Open
ANG-LD opened this issue Dec 30, 2024 · 1 comment
Open

The type of MySQL query results differs from the actual ones #4088

ANG-LD opened this issue Dec 30, 2024 · 1 comment
Assignees
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@ANG-LD
Copy link

ANG-LD commented Dec 30, 2024

          >@gqcn你好,mysql字段类型int unsigned DEFAULT NULL时,查询后值类型为string,期望的类型是int
CREATE TABLE `test_table` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `number` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
package main

import (
	"fmt"
         _ "github.com/gogf/gf/contrib/drivers/mysql/v2"
	"github.com/gogf/gf/v2/frame/g"
)

func main() {
	one, err := g.Model("test_table").One()
	if err != nil {
		panic(err)
	}
	id, _ := one["id"]
	fmt.Printf("id: %V\n", id)
	number, _ := one["number"]
	fmt.Printf("number: %V\n", number)
}

image

Originally posted by @ANG-LD in #4067 (comment)

@gqcn gqcn added the bug It is confirmed a bug, but don't worry, we'll handle it. label Jan 22, 2025
@gqcn gqcn self-assigned this Jan 22, 2025
@gqcn
Copy link
Member

gqcn commented Jan 22, 2025

@ANG-LD 我在 #4107 解决了这个问题,但这个pr需要更多的时间进行review。

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

2 participants