From 619d306cef27adf4681bd04edfc0a620217471b2 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Thu, 10 Sep 2020 10:55:02 +0800 Subject: [PATCH] ignore (-) when creating default values, #3434 --- migrator/migrator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrator/migrator.go b/migrator/migrator.go index 53fd5ac0..4b069c8a 100644 --- a/migrator/migrator.go +++ b/migrator/migrator.go @@ -71,7 +71,7 @@ func (m Migrator) FullDataTypeOf(field *schema.Field) (expr clause.Expr) { defaultStmt := &gorm.Statement{Vars: []interface{}{field.DefaultValueInterface}} m.Dialector.BindVarTo(defaultStmt, defaultStmt, field.DefaultValueInterface) expr.SQL += " DEFAULT " + m.Dialector.Explain(defaultStmt.SQL.String(), field.DefaultValueInterface) - } else { + } else if field.DefaultValue != "(-)" { expr.SQL += " DEFAULT " + field.DefaultValue } }