From 19a96b5c11ca4aa2d9ef93f43dea49d7760df9ab Mon Sep 17 00:00:00 2001 From: wclssdn Date: Thu, 23 Jun 2022 19:25:10 +0800 Subject: [PATCH] Update migrator.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix bug: 字符串默认值未使用引号包裹导致sql格式非法 --- migrator/migrator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrator/migrator.go b/migrator/migrator.go index df4dd0a4..b2cd4c9f 100644 --- a/migrator/migrator.go +++ b/migrator/migrator.go @@ -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 +`"` } }