snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
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
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
This commit is contained in:
59
internal/sql/ast/alter_table_cmd.go
Normal file
59
internal/sql/ast/alter_table_cmd.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package ast
|
||||
|
||||
import "github.com/sqlc-dev/sqlc/internal/sql/format"
|
||||
|
||||
const (
|
||||
AT_AddColumn AlterTableType = iota
|
||||
AT_AlterColumnType
|
||||
AT_DropColumn
|
||||
AT_DropNotNull
|
||||
AT_SetNotNull
|
||||
)
|
||||
|
||||
type AlterTableType int
|
||||
|
||||
func (t AlterTableType) String() string {
|
||||
switch t {
|
||||
case AT_AddColumn:
|
||||
return "AddColumn"
|
||||
case AT_AlterColumnType:
|
||||
return "AlterColumnType"
|
||||
case AT_DropColumn:
|
||||
return "DropColumn"
|
||||
case AT_DropNotNull:
|
||||
return "DropNotNull"
|
||||
case AT_SetNotNull:
|
||||
return "SetNotNull"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
type AlterTableCmd struct {
|
||||
Tag NodeTag[AlterTableCmd] `json:"tag"`
|
||||
|
||||
Subtype AlterTableType `json:"subtype"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Def *ColumnDef `json:"def,omitempty"`
|
||||
Newowner *RoleSpec `json:"newowner,omitempty"`
|
||||
Behavior DropBehavior `json:"behavior"`
|
||||
MissingOk bool `json:"missing_ok"`
|
||||
}
|
||||
|
||||
func (n *AlterTableCmd) Pos() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (n *AlterTableCmd) Format(buf *TrackedBuffer, d format.Dialect) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
switch n.Subtype {
|
||||
case AT_AddColumn:
|
||||
buf.WriteString(" ADD COLUMN ")
|
||||
case AT_DropColumn:
|
||||
buf.WriteString(" DROP COLUMN ")
|
||||
}
|
||||
|
||||
buf.astFormat(n.Def, d)
|
||||
}
|
||||
Reference in New Issue
Block a user