From 363bd125751a1097662b8bcacc282fa05b317340 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Fri, 16 Jun 2023 19:27:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generator/main.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/generator/main.go b/generator/main.go index 9a9bad55..86e7d676 100644 --- a/generator/main.go +++ b/generator/main.go @@ -127,7 +127,13 @@ func GenFromPath(mdir string, cols []Column, tableName string, tableComment stri typeName := typeForMysqlToGo[col.GetType()] var defaultString string if col.DefaultValue != nil { - defaultString = "default:" + *col.DefaultValue + ";" + switch typeName { + case "*int64", "*uint64", "*float64", "*bool": + defaultString = "default:" + strings.Trim(*col.DefaultValue, "'") + ";" + default: + defaultString = "default:" + *col.DefaultValue + ";" + } + } else { switch typeName { @@ -138,11 +144,11 @@ func GenFromPath(mdir string, cols []Column, tableName string, tableComment stri case "*[]byte": defaultString = "default:'';" case "*int64", "*uint64": - defaultString = "default:'0';" + defaultString = "default:0;" case "*float64": - defaultString = "default:'0.0';" + defaultString = "default: 0.0;" case "*bool": - defaultString = "default:'0';" + defaultString = "default:0;" default: fieldName = "// " + fieldName + " " + col.Type }