Files
upstream-sqlc/internal/sql/ast/alter_table_stmt.go
upstream-mirror 0f4df23290
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
2026-09-16 02:17:34 +05:00

39 lines
1.1 KiB
Go

package ast
import "github.com/sqlc-dev/sqlc/internal/sql/format"
type AlterTableStmt struct {
Tag NodeTag[AlterTableStmt] `json:"tag"`
// TODO: Only TableName or Relation should be defined
Relation *RangeVar `json:"relation,omitempty"`
Table *TableName `json:"table,omitempty"`
Cmds *List `json:"cmds,omitempty"`
MissingOk bool `json:"missing_ok"`
Relkind ObjectType `json:"relkind"`
// Incomplete marks a statement whose source carried syntax this node
// does not model, such as column constraints beyond plain NOT NULL and
// PRIMARY KEY on an added column. No faithful rendering exists for it.
Incomplete bool `json:"incomplete"`
}
func (n *AlterTableStmt) Pos() int {
return 0
}
func (n *AlterTableStmt) Format(buf *TrackedBuffer, d format.Dialect) {
if n == nil {
return
}
// An incomplete statement cannot be printed back: part of its source
// was parsed away. Render nothing, which no verification accepts, so
// the formatter keeps the statement as written.
if n.Incomplete {
return
}
buf.WriteString("ALTER TABLE ")
buf.astFormat(n.Relation, d)
buf.astFormat(n.Table, d)
buf.astFormat(n.Cmds, d)
}