Update migrator.go

fix bug: 字符串默认值未使用引号包裹导致sql格式非法
This commit is contained in:
wclssdn 2022-06-23 19:25:10 +08:00 committed by GitHub
parent 7cf0819f93
commit 19a96b5c11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,7 +87,7 @@ func (m Migrator) FullDataTypeOf(field *schema.Field) (expr clause.Expr) {
m.Dialector.BindVarTo(defaultStmt, defaultStmt, field.DefaultValueInterface)
expr.SQL += " DEFAULT " + m.Dialector.Explain(defaultStmt.SQL.String(), field.DefaultValueInterface)
} else if field.DefaultValue != "(-)" {
expr.SQL += " DEFAULT " + field.DefaultValue
expr.SQL += ` DEFAULT "` + field.DefaultValue +`"`
}
}