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

converting field json string to map failed after upgrading to v2.6.0 #3218

Closed
gqcn opened this issue Dec 19, 2023 · 0 comments
Closed

converting field json string to map failed after upgrading to v2.6.0 #3218

gqcn opened this issue Dec 19, 2023 · 0 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

@gqcn
Copy link
Member

gqcn commented Dec 19, 2023

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

go 1.20.0

2. What version of GoFrame are you using?

goframe v2.6.0

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

yes

4. What did you do?

sql:

DROP TABLE IF EXISTS `sys_config`;
CREATE TABLE `sys_config`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '配置名称',
  `value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '配置值',
  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `name`(`name`(191)) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 50 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;

-- ----------------------------
-- Records of sys_config
-- ----------------------------
INSERT INTO `sys_config` VALUES (49, 'site', '{\"banned_ip\":\"22\",\"filings\":\"2222\",\"fixed_page\":\"\",\"site_name\":\"22\",\"version\":\"22\"}', '2023-12-19 14:08:25', '2023-12-19 14:08:25');

main.go

package main

import (
	"fmt"

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

	"github.com/gogf/gf/v2/frame/g"
)

func main() {
	type SysConfigInfo struct {
		Name  string            `json:"name"      ` // 配置名称
		Value map[string]string `json:"value"     ` // 配置值
	}

	var configData SysConfigInfo
	err := g.Model("sys_config").Scan(&configData)
	fmt.Println(err)
	fmt.Println(configData)
}

5. What did you expect to see?

{site map[banned_ip:22 filings:2222 fixed_page: site_name:22 version:22]}

6. What did you see instead?

{site map[]}
@gqcn gqcn self-assigned this Dec 19, 2023
@gqcn gqcn added bug It is confirmed a bug, but don't worry, we'll handle it. wip labels Dec 19, 2023
gqcn added a commit that referenced this issue Dec 19, 2023
gqcn added a commit that referenced this issue Dec 19, 2023
gqcn added a commit that referenced this issue Dec 19, 2023
@gqcn gqcn added done This issue is done, which may be release in next version. and removed wip labels Jan 22, 2024
@gqcn gqcn closed this as completed Jan 22, 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. done This issue is done, which may be release in next version.
Projects
None yet
Development

No branches or pull requests

1 participant