比如某个article表的title标题字段,数据库指定空字符串默认值,Gen 生成 model 的时候,gorm 标签如下:
Title string gorm:"column:title;type:character varying(120);default:''::character varying";comment:标题" json:"title"
这个看起来似乎没有问题,但是实际使用的时候,title 字段如果不赋值,数据库插入的默认值是:::character varying 字符串,并不是预期的空字符串。
我不知道这个算不算 bug,我每次生成 model 之后,都需要把 default:''::character varying 批量替换成 default:'' 才达到预期效果。
请你们有空验证一下,不胜感激。
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Comment From: okki-op
遇到同款bug