-
Notifications
You must be signed in to change notification settings - Fork 0
/
table_index_parameters.go
54 lines (47 loc) · 1.18 KB
/
table_index_parameters.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
47
48
49
50
51
52
53
54
package gosql
import "strings"
//[ INCLUDE ( column_name [, ... ] ) ]
//[ WITH ( storage_parameter [ = value] [, ... ] ) ]
//[ USING INDEX TABLESPACE tablespace_name ]
type indexParameters struct {
// include
include expression
// with
with expression
// using index tablespace
tableSpace string
}
// With get with
func (i *indexParameters) With() *expression {
return &i.with
}
// Include get include
func (i *indexParameters) Include() *expression {
return &i.include
}
// TableSpace set tableSpace
func (i *indexParameters) TableSpace(tableSpace string) *indexParameters {
i.tableSpace = tableSpace
return i
}
// String render index parameters
func (i *indexParameters) String() string {
if i.IsEmpty() {
return ""
}
b := strings.Builder{}
if i.include.Len() > 0 {
b.WriteString(" INCLUDE (" + i.include.String(", ") + ")")
}
if i.with.Len() > 0 {
b.WriteString(" WITH (" + i.with.String(", ") + ")")
}
if i.tableSpace != "" {
b.WriteString(" USING INDEX TABLESPACE " + i.tableSpace)
}
return b.String()
}
// IsEmpty is index parameter empty
func (i *indexParameters) IsEmpty() bool {
return i == nil || (i.tableSpace == "" && i.include.Len() == 0 && i.with.Len() == 0)
}