Closed Gallery2000 closed 6 months ago
我在我的机器上试了pgsql没问题,另这个和mysql没有关系,只要数据库支持json类型的字段就可以
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
I tried pgsql on my machine and there was no problem. This has nothing to do with mysql, as long as the database supports json type fields.
社区的这个问题是我写的,看到说是2.64是正常的,我降级后将生成的文件和2.7生成的文件对比了下,发现了问题。 2.6.4生成的: 2.7 以及 2.7.1 生成的: 通过对比发现2.7 生成的多了orm标签 现在有两个解决办法:
希望可以改下,官方工具不生成这个orm标签
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
I wrote this question in the community. I saw that it was normal for 2.64. After downgrading, I compared the generated files with those generated by 2.7 and found the problem. Generated by 2.6.4: 2.7 and 2.7.1 generated: Through comparison, it was found that 2.7 generated more ORM tags. There are two solutions now:
- Modify the generated file and delete the orm tag
- Do not modify the generated file, but write the orm tag in the upper-level structure.
I hope it can be changed. The official tool does not generate this ORM tag.
对不起,我更正一下,如果插入的字段为元组类型并且len为0 ,则会提示错误: Error: Error 3140 (22032): Invalid JSON text: "The document is empty." at position 0 in value for column 'xxx.xxx'.
dao.Message.Ctx(ctx).Data(model.MessageItem{
Message:&entity.Message{
...
},
Embeds: make([]MessageEmbed, 0),
}).Insert()
dao.Message.Ctx(ctx).Data(message).FieldsEx(fieldsEx).Insert()
目前是用FieldsEx解决空值无法被映射为json的问题,但感觉还是老版本自动映射更加好用。
Go version
1.21
GoFrame version
2.7
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
评论区已经有人反馈了,所有的json都字段都被解析成了空字符插入到数据库。当我把gf版本降到2.64执行gf gen dao后一切就正常了。
What did you see happen?
help
What did you expect to see?
help