forked from sqlc-dev/sqlc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalter_table_cmd.go
More file actions
55 lines (48 loc) · 911 Bytes
/
alter_table_cmd.go
File metadata and controls
55 lines (48 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package ast
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 {
Subtype AlterTableType
Name *string
Def *ColumnDef
Newowner *RoleSpec
Behavior DropBehavior
MissingOk bool
}
func (n *AlterTableCmd) Pos() int {
return 0
}
func (n *AlterTableCmd) Format(buf *TrackedBuffer) {
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)
}