From 3c9bea03bb4cbdf920ae5a32753e63681da1fff2 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 28 Sep 2019 18:51:59 +0800 Subject: [PATCH] fix default on postgres --- dialect_postgres.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dialect_postgres.go b/dialect_postgres.go index 8981132b..aa17ac31 100644 --- a/dialect_postgres.go +++ b/dialect_postgres.go @@ -1046,8 +1046,8 @@ WHERE c.relkind = 'r'::char AND c.relname = $1%s AND f.attnum > 0 ORDER BY f.att col.Length = maxLen if !col.DefaultIsEmpty && (col.SQLType.IsText() || col.SQLType.IsTime()) { - if col.Default == "''::character varying" { - col.Default = "''" + if strings.HasSuffix(col.Default, "::character varying") { + col.Default = strings.TrimRight(col.Default, "::character varying") } else if !strings.HasPrefix(col.Default, "'") { col.Default = "'" + col.Default + "'" }