-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclause_exporter_test.go
156 lines (121 loc) · 3.12 KB
/
clause_exporter_test.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package genorm
func NewWhereConditionClause[T Table](condition TypedTableExpr[T, WrappedPrimitive[bool]]) *whereConditionClause[T] {
return &whereConditionClause[T]{
condition: condition,
}
}
func (c *whereConditionClause[T]) GetCondition() TypedTableExpr[T, WrappedPrimitive[bool]] {
return c.condition
}
func (c *whereConditionClause[T]) Set(condition TypedTableExpr[T, WrappedPrimitive[bool]]) error {
return c.set(condition)
}
func (c *whereConditionClause[T]) Exists() bool {
return c.exists()
}
func (c *whereConditionClause[T]) GetExpr() (string, []ExprType, error) {
return c.getExpr()
}
func NewGroupClause[T Table](exprs []TableExpr[T]) *groupClause[T] {
return &groupClause[T]{
exprs: exprs,
}
}
func (c *groupClause[T]) GetCondition() []TableExpr[T] {
return c.exprs
}
func (c *groupClause[T]) Set(exprs []TableExpr[T]) error {
return c.set(exprs)
}
func (c *groupClause[T]) Exists() bool {
return c.exists()
}
func (c *groupClause[T]) GetExpr() (string, []ExprType, error) {
return c.getExpr()
}
type OrderItem[T Table] orderItem[T]
func NewOrderItem[T Table](expr TableExpr[T], direction OrderDirection) OrderItem[T] {
return OrderItem[T]{
expr: expr,
direction: direction,
}
}
func (c *OrderItem[T]) Value() (TableExpr[T], OrderDirection) {
return c.expr, c.direction
}
func NewOrderClause[T Table](items []OrderItem[T]) *orderClause[T] {
orderItems := make([]orderItem[T], 0, len(items))
for _, item := range items {
orderItems = append(orderItems, orderItem[T](item))
}
return &orderClause[T]{
orderExprs: orderItems,
}
}
func (c *orderClause[T]) GetItems() []OrderItem[T] {
items := make([]OrderItem[T], 0, len(c.orderExprs))
for _, item := range c.orderExprs {
items = append(items, OrderItem[T](item))
}
return items
}
func (c *orderClause[T]) Add(item OrderItem[T]) error {
return c.add(orderItem[T](item))
}
func (c *orderClause[T]) Exists() bool {
return c.exists()
}
func (c *orderClause[T]) GetExpr() (string, []ExprType, error) {
return c.getExpr()
}
func NewLimitClause(limit uint64) *limitClause {
return &limitClause{
limit: limit,
}
}
func (c *limitClause) GetLimit() uint64 {
return c.limit
}
func (c *limitClause) Set(limit uint64) error {
return c.set(limit)
}
func (c *limitClause) Exists() bool {
return c.exists()
}
func (c *limitClause) GetExpr() (string, []ExprType, error) {
return c.getExpr()
}
func NewOffsetClause(offset uint64) *offsetClause {
return &offsetClause{
offset: offset,
}
}
func (c *offsetClause) GetOffset() uint64 {
return c.offset
}
func (c *offsetClause) Set(offset uint64) error {
return c.set(offset)
}
func (c *offsetClause) Exists() bool {
return c.exists()
}
func (c *offsetClause) GetExpr() (string, []ExprType, error) {
return c.getExpr()
}
func NewLockClause(lockType LockType) *lockClause {
return &lockClause{
lockType: lockType,
}
}
func (c *lockClause) GetLockType() LockType {
return c.lockType
}
func (c *lockClause) Set(lockType LockType) error {
return c.set(lockType)
}
func (c *lockClause) Exists() bool {
return c.exists()
}
func (c *lockClause) GetExpr() (string, []ExprType, error) {
return c.getExpr()
}