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 }