add delimiters between COMMENT ON COLUMN... for Postgres (#2156)
Fix bug: CreateTableSQL func generates invalid SQL without ";" delimiters. Reviewed-on: https://gitea.com/xorm/xorm/pulls/2156 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Dmitry Narizhnykh <slotix@noreply.gitea.io> Co-committed-by: Dmitry Narizhnykh <slotix@noreply.gitea.io>
This commit is contained in:
parent
f1bfc5ce98
commit
71270edfcc
|
@ -1343,14 +1343,14 @@ func (db *postgres) CreateTableSQL(ctx context.Context, queryer core.Queryer, ta
|
||||||
commentSQL := "; "
|
commentSQL := "; "
|
||||||
if table.Comment != "" {
|
if table.Comment != "" {
|
||||||
// support schema.table -> "schema"."table"
|
// 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() {
|
for _, colName := range table.ColumnsSeq() {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
|
|
||||||
if len(col.Comment) > 0 {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue