This commit is contained in:
eson 2023-06-16 19:27:08 +08:00
parent 90871c1ab0
commit 363bd12575

View File

@ -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
}