From 42c3c9c140a917ab0aeb56635c35e250b8c5698e Mon Sep 17 00:00:00 2001 From: jiang4869 <1121429190@qq.com> Date: Mon, 10 Jan 2022 01:03:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E5=AD=97=E6=AE=B5=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC=E4=B8=BANULL=EF=BC=8C=E5=B9=B6=E4=B8=94=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E4=B8=8D=E8=AE=BE=E7=BD=AE=E4=B8=BA=E6=8C=87=E9=92=88?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0default:null=E7=9A=84tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/view/model/model.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data/view/model/model.go b/data/view/model/model.go index 1eda56e..7555dfc 100755 --- a/data/view/model/model.go +++ b/data/view/model/model.go @@ -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)