-
Notifications
You must be signed in to change notification settings - Fork 0
/
select_stmt.go
46 lines (35 loc) · 1.11 KB
/
select_stmt.go
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
package goastutil
import (
"fmt"
"go/ast"
)
type SelectStmt struct {
parent Stmt
*ast.SelectStmt
}
func NewSelectStmt(parent Stmt, stmt *ast.SelectStmt) *SelectStmt {
return &SelectStmt{SelectStmt: stmt, parent: parent}
}
func (s *SelectStmt) PrependStmt(st string) error {
return prependStmt(st, s.parent, s.SelectStmt)
}
func (s *SelectStmt) AppendStmt(st string) error {
return appendStmt(st, s.parent, s.SelectStmt)
}
func (ss *SelectStmt) StmtType() StmtType {
return SelectStmtType
}
func (ss *SelectStmt) Body() *BlockStmt {
return NewBlockStmt(ss, ss.SelectStmt.Body)
}
// TODO: add PrependCase, InsertCase, and RemoveCase
func (ss *SelectStmt) PrependCase() error { return nil }
func (ss *SelectStmt) InsertCase() error { return nil }
func (ss *SelectStmt) RemoveCase() error { return nil }
// String returns a string representation of the SelectStmt.
//
// It returns a formatted string containing the "select" keyword and the body of the SelectStmt.
// The returned string is suitable for displaying or further processing.
func (ss *SelectStmt) String() string {
return fmt.Sprintf("select %s", ss.Body())
}