forked from wheelcomplex/kmg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AndWhereCondition.go
37 lines (33 loc) · 996 Bytes
/
AndWhereCondition.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
package MysqlAst
func NewAndWhereCondition() *AndWhereCondition {
return &AndWhereCondition{}
}
type AndWhereCondition struct {
List []PreparedNode
}
func (n *AndWhereCondition) GetPrepareParameter() (string, []string) {
//TODO 去掉empty的节点?
return joinPrepareNode([]PreparedNode(n.List), ") AND (", "(", ")")
}
func (n *AndWhereCondition) Copy() PreparedNode {
s := make([]PreparedNode, len(n.List))
for i := range n.List {
s[i] = n.List[i].Copy()
}
return &AndWhereCondition{List: s}
}
func (n *AndWhereCondition) IsEmpty() bool {
return len(n.List) == 0
}
func (n *AndWhereCondition) AddAndCondition(node PreparedNode) *AndWhereCondition {
n.List = append(n.List, node)
return n
}
func (n *AndWhereCondition) AddPrepare(text string, parameterList ...string) *AndWhereCondition {
n.List = append(n.List, Prepare(text, parameterList...))
return n
}
func (n *AndWhereCondition) AddNode(node PreparedNode) *AndWhereCondition {
n.List = append(n.List, node)
return n
}