Merge pull request #192 from jiang4869/master

当字段默认值为NULL,并且结构不设置为指针时,添加default:null的tag
This commit is contained in:
xxj
2022-01-10 06:07:22 +08:00
committed by GitHub

View File

@@ -184,7 +184,10 @@ func (m *_Model) genTableElement(cols []ColumnsInfo) (el []genstruct.GenElement)
tmp.AddTag(_tagGorm, "type:"+v.Type)
if !v.IsNull {
tmp.AddTag(_tagGorm, "not null")
}
} else if v.IsNull && !config.GetIsNullToPoint() {
// 当该字段默认值为null并且结构不用指针类型时添加default:null的tag
tmp.AddTag(_tagGorm,"default:null")
}
// default tag
if len(v.Gormt) > 0 {
tmp.AddTag(_tagGorm, v.Gormt)