Fix invalid SQL for pgsql column type change
This commit is contained in:
@@ -2,6 +2,7 @@ package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/pkg/dal"
|
||||
"github.com/cortezaproject/corteza/server/store/adapters/rdbms/ddl"
|
||||
@@ -16,6 +17,13 @@ type (
|
||||
is *informationSchema
|
||||
d *postgresDialect
|
||||
}
|
||||
|
||||
reTypeColumn struct {
|
||||
Dialect *postgresDialect
|
||||
Table string
|
||||
Column string
|
||||
Type *ddl.ColumnType
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -80,7 +88,7 @@ func (dd *dataDefiner) ColumnRename(ctx context.Context, t string, o string, n s
|
||||
}
|
||||
|
||||
func (dd *dataDefiner) ColumnReType(ctx context.Context, t string, col string, tp *ddl.ColumnType) error {
|
||||
return ddl.Exec(ctx, dd.conn, &ddl.ReTypeColumn{
|
||||
return ddl.Exec(ctx, dd.conn, &reTypeColumn{
|
||||
Dialect: dd.d,
|
||||
Table: t,
|
||||
Column: col,
|
||||
@@ -109,3 +117,12 @@ func (dd *dataDefiner) IndexDrop(ctx context.Context, t, i string) error {
|
||||
Ident: i,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *reTypeColumn) ToSQL() (sql string, aa []interface{}, err error) {
|
||||
return fmt.Sprintf(
|
||||
`ALTER TABLE %s ALTER COLUMN %s TYPE %s`,
|
||||
c.Dialect.QuoteIdent(c.Table),
|
||||
c.Dialect.QuoteIdent(c.Column),
|
||||
c.Type.Name,
|
||||
), nil, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user