Skip to content

Commit

Permalink
Merge pull request xxjwxc#192 from jiang4869/master
Browse files Browse the repository at this point in the history
当字段默认值为NULL,并且结构不设置为指针时,添加default:null的tag
  • Loading branch information
xxjwxc authored Jan 9, 2022
2 parents 9e62d21 + 42c3c9c commit ce6259f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion data/view/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ce6259f

Please sign in to comment.