From 44a854f05e99c40a533ea4c9ef9067d24096c5fe Mon Sep 17 00:00:00 2001 From: Dmitry Narizhnykh Date: Tue, 14 Jun 2022 03:26:12 +0800 Subject: [PATCH] add delimiters between COMMENT ON COLUMN... for Postgres Fix bug: CreateTableSQL func generates invalid SQL without ";" delimiters. --- dialects/postgres.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dialects/postgres.go b/dialects/postgres.go index ba73aad7..89427e21 100644 --- a/dialects/postgres.go +++ b/dialects/postgres.go @@ -1344,14 +1344,14 @@ func (db *postgres) CreateTableSQL(ctx context.Context, queryer core.Queryer, ta commentSQL := "; " if table.Comment != "" { // support schema.table -> "schema"."table" - commentSQL += fmt.Sprintf("COMMENT ON TABLE %s IS '%s'", quoter.Quote(tableName), table.Comment) + commentSQL += fmt.Sprintf("COMMENT ON TABLE %s IS '%s'; ", quoter.Quote(tableName), table.Comment) } for _, colName := range table.ColumnsSeq() { col := table.GetColumn(colName) if len(col.Comment) > 0 { - commentSQL += fmt.Sprintf("COMMENT ON COLUMN %s.%s IS '%s'", quoter.Quote(tableName), quoter.Quote(col.Name), col.Comment) + commentSQL += fmt.Sprintf("COMMENT ON COLUMN %s.%s IS '%s'; ", quoter.Quote(tableName), quoter.Quote(col.Name), col.Comment) } }