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 gJsonSupport parameter of gf gen dao does not take effect, and the generated entity model is still string #2746

Closed
WankkoRee opened this issue Jul 6, 2023 · 5 comments · Fixed by #3309
Assignees
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. help wanted

Comments

@WankkoRee
Copy link
Contributor

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

go version go1.20.5 windows/amd64

2. What version of GoFrame are you using?

v2.4.4

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

可以复现,在文档评论区中也有其他开发者反馈存在同样的问题:https://goframe.org/pages/viewpage.action?pageId=3673173

4. What did you do?

我用的是MariaDB,但是看上面其他开发者提到MySQL也是存在同样的问题的。

CREATE TABLE `demo` (
    `tag` json NOT NULL
);
hack/config.yaml

# CLI tool, only in development environment.
# https://goframe.org/pages/viewpage.action?pageId=3673173
gfcli:
  gen:
    dao:
      - link: "mysql:root:123456@tcp(127.0.0.1:3306)/xxx"
        jsonCase: "Snake"
        gJsonSupport: true
internal/model/entity/demo.go

// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================

package entity

import (
	"github.com/gogf/gf/v2/os/gtime"
)

// Demo is the golang structure for table demo.
type Article struct {
	Tag        string      `json:"tag"        // 标签
}

5. What did you expect to see?

type Article struct {
	Tag        *gjson.Json      `json:"tag"        // 标签
}

6. What did you see instead?

type Article struct {
	Tag        string      `json:"tag"        // 标签
}
@Issues-translate-bot Issues-translate-bot changed the title gf gen daogJsonSupport参数不生效,生成的entity模型依旧是string The gJsonSupport parameter of gf gen dao does not take effect, and the generated entity model is still string Jul 6, 2023
@WankkoRee
Copy link
Contributor Author

看了下文档评论区说的MySQL的问题应该是已经修复了的,但是MariaDB的问题依然存在,应该是其实现json的机制不一样造成的:https://mariadb.com/kb/en/json-data-type/

所以最终数据表中定义的tag字段是longtext类型的,然后额外带一个json_valid(`tag`)的检查。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


After reading the comment area of ​​the document, the MySQL problem should have been fixed, but the MariaDB problem still exists, which should be caused by the different mechanism for implementing json: https://mariadb.com /kb/en/json-data-type/

So the tag field defined in the final data table is of longtext type, and then an additional json_valid(`tag`) check is added.

@gqcn gqcn added bug It is confirmed a bug, but don't worry, we'll handle it. help wanted labels Sep 21, 2023
@github-actions
Copy link

Hello @WankkoRee. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!
你好 @WankkoRee。我们喜欢您的提案/反馈,并希望您或其他社区成员通过拉取请求做出贡献。我们提前感谢您的贡献,并期待对其进行审查。

@gqcn
Copy link
Member

gqcn commented Sep 21, 2023

看了下文档评论区说的MySQL的问题应该是已经修复了的,但是MariaDB的问题依然存在,应该是其实现json的机制不一样造成的:https://mariadb.com/kb/en/json-data-type/

所以最终数据表中定义的tag字段是longtext类型的,然后额外带一个json_valid(`tag`)的检查。

了解,这块等着需要的小伙伴来提供PR改进吧。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


After reading the documentation comment area, the problem with MySQL should have been fixed, but the problem with MariaDB still exists. It should be caused by the different mechanism of implementing json: https://mariadb. com/kb/en/json-data-type/

So the tag field defined in the final data table is of longtext type, and then has an additional json_valid(`tag`) check.

Understood, this is waiting for friends who need it to provide PR improvements.

@oldme-git oldme-git self-assigned this Feb 4, 2024
oldme-git added a commit to oldme-git/gf that referenced this issue Feb 7, 2024
# Conflicts:
#	cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go
oldme-git added a commit to oldme-git/gf that referenced this issue Feb 28, 2024
oldme-git added a commit to oldme-git/gf that referenced this issue Feb 29, 2024
oldme-git added a commit to oldme-git/gf that referenced this issue Mar 1, 2024
oldme-git added a commit to oldme-git/gf that referenced this issue Mar 5, 2024
@gqcn gqcn closed this as completed in #3309 Mar 6, 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. help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants