-
Notifications
You must be signed in to change notification settings - Fork 1
/
tuple.go
196 lines (174 loc) · 5 KB
/
tuple.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
package genorm
type Tuple interface {
Exprs() []Expr
Columns() []ColumnFieldExprType
}
type TuplePointer[T any] interface {
Exprs() []Expr
Columns() []ColumnFieldExprType
*T
}
type Tuple2Struct[
S Table,
T1 ExprType, U1 ColumnFieldExprTypePointer[T1],
T2 ExprType, U2 ColumnFieldExprTypePointer[T2],
] struct {
value1 T1
value2 T2
expr1 TypedTableExpr[S, T1]
expr2 TypedTableExpr[S, T2]
}
func Tuple2[
S Table,
T1 ExprType, U1 ColumnFieldExprTypePointer[T1],
T2 ExprType, U2 ColumnFieldExprTypePointer[T2],
](expr1 TypedTableExpr[S, T1], expr2 TypedTableExpr[S, T2]) *Tuple2Struct[S, T1, U1, T2, U2] {
return &Tuple2Struct[S, T1, U1, T2, U2]{
expr1: expr1,
expr2: expr2,
}
}
func (t *Tuple2Struct[_, _, _, _, _]) Exprs() []Expr {
return []Expr{t.expr1, t.expr2}
}
func (t *Tuple2Struct[_, _, U1, _, U2]) Columns() []ColumnFieldExprType {
return []ColumnFieldExprType{
U1(&t.value1),
U2(&t.value2),
}
}
func (t *Tuple2Struct[_, T1, _, T2, _]) Values() (T1, T2) {
return t.value1, t.value2
}
type Tuple3Struct[
S Table,
T1 ExprType, U1 ColumnFieldExprTypePointer[T1],
T2 ExprType, U2 ColumnFieldExprTypePointer[T2],
T3 ExprType, U3 ColumnFieldExprTypePointer[T3],
] struct {
value1 T1
value2 T2
value3 T3
expr1 TypedTableExpr[S, T1]
expr2 TypedTableExpr[S, T2]
expr3 TypedTableExpr[S, T3]
}
func Tuple3[
S Table,
T1 ExprType, U1 ColumnFieldExprTypePointer[T1],
T2 ExprType, U2 ColumnFieldExprTypePointer[T2],
T3 ExprType, U3 ColumnFieldExprTypePointer[T3],
](expr1 TypedTableExpr[S, T1], expr2 TypedTableExpr[S, T2], expr3 TypedTableExpr[S, T3]) *Tuple3Struct[S, T1, U1, T2, U2, T3, U3] {
return &Tuple3Struct[S, T1, U1, T2, U2, T3, U3]{
expr1: expr1,
expr2: expr2,
expr3: expr3,
}
}
func (t *Tuple3Struct[_, _, _, _, _, _, _]) Exprs() []Expr {
return []Expr{t.expr1, t.expr2, t.expr3}
}
func (t *Tuple3Struct[_, _, U1, _, U2, _, U3]) Columns() []ColumnFieldExprType {
return []ColumnFieldExprType{
U1(&t.value1),
U2(&t.value2),
U3(&t.value3),
}
}
func (t *Tuple3Struct[_, T1, _, T2, _, T3, _]) Values() (T1, T2, T3) {
return t.value1, t.value2, t.value3
}
type Tuple4Struct[
S Table,
T1 ExprType, U1 ColumnFieldExprTypePointer[T1],
T2 ExprType, U2 ColumnFieldExprTypePointer[T2],
T3 ExprType, U3 ColumnFieldExprTypePointer[T3],
T4 ExprType, U4 ColumnFieldExprTypePointer[T4],
] struct {
value1 T1
value2 T2
value3 T3
value4 T4
expr1 TypedTableExpr[S, T1]
expr2 TypedTableExpr[S, T2]
expr3 TypedTableExpr[S, T3]
expr4 TypedTableExpr[S, T4]
}
func Tuple4[
S Table,
T1 ExprType, U1 ColumnFieldExprTypePointer[T1],
T2 ExprType, U2 ColumnFieldExprTypePointer[T2],
T3 ExprType, U3 ColumnFieldExprTypePointer[T3],
T4 ExprType, U4 ColumnFieldExprTypePointer[T4],
](expr1 TypedTableExpr[S, T1], expr2 TypedTableExpr[S, T2], expr3 TypedTableExpr[S, T3], expr4 TypedTableExpr[S, T4]) *Tuple4Struct[S, T1, U1, T2, U2, T3, U3, T4, U4] {
return &Tuple4Struct[S, T1, U1, T2, U2, T3, U3, T4, U4]{
expr1: expr1,
expr2: expr2,
expr3: expr3,
expr4: expr4,
}
}
func (t *Tuple4Struct[_, _, _, _, _, _, _, _, _]) Exprs() []Expr {
return []Expr{t.expr1, t.expr2, t.expr3, t.expr4}
}
func (t *Tuple4Struct[_, _, U1, _, U2, _, U3, _, U4]) Columns() []ColumnFieldExprType {
return []ColumnFieldExprType{
U1(&t.value1),
U2(&t.value2),
U3(&t.value3),
U4(&t.value4),
}
}
func (t *Tuple4Struct[_, T1, _, T2, _, T3, _, T4, _]) Values() (T1, T2, T3, T4) {
return t.value1, t.value2, t.value3, t.value4
}
type Tuple5Struct[
S Table,
T1 ExprType, U1 ColumnFieldExprTypePointer[T1],
T2 ExprType, U2 ColumnFieldExprTypePointer[T2],
T3 ExprType, U3 ColumnFieldExprTypePointer[T3],
T4 ExprType, U4 ColumnFieldExprTypePointer[T4],
T5 ExprType, U5 ColumnFieldExprTypePointer[T5],
] struct {
value1 T1
value2 T2
value3 T3
value4 T4
value5 T5
expr1 TypedTableExpr[S, T1]
expr2 TypedTableExpr[S, T2]
expr3 TypedTableExpr[S, T3]
expr4 TypedTableExpr[S, T4]
expr5 TypedTableExpr[S, T5]
}
func Tuple5[
S Table,
T1 ExprType, U1 ColumnFieldExprTypePointer[T1],
T2 ExprType, U2 ColumnFieldExprTypePointer[T2],
T3 ExprType, U3 ColumnFieldExprTypePointer[T3],
T4 ExprType, U4 ColumnFieldExprTypePointer[T4],
T5 ExprType, U5 ColumnFieldExprTypePointer[T5],
](expr1 TypedTableExpr[S, T1], expr2 TypedTableExpr[S, T2], expr3 TypedTableExpr[S, T3], expr4 TypedTableExpr[S, T4], expr5 TypedTableExpr[S, T5]) *Tuple5Struct[S, T1, U1, T2, U2, T3, U3, T4, U4, T5, U5] {
return &Tuple5Struct[S, T1, U1, T2, U2, T3, U3, T4, U4, T5, U5]{
expr1: expr1,
expr2: expr2,
expr3: expr3,
expr4: expr4,
expr5: expr5,
}
}
func (t *Tuple5Struct[_, _, _, _, _, _, _, _, _, _, _]) Exprs() []Expr {
return []Expr{t.expr1, t.expr2, t.expr3, t.expr4, t.expr5}
}
func (t *Tuple5Struct[_, _, U1, _, U2, _, U3, _, U4, _, U5]) Columns() []ColumnFieldExprType {
return []ColumnFieldExprType{
U1(&t.value1),
U2(&t.value2),
U3(&t.value3),
U4(&t.value4),
U5(&t.value5),
}
}
func (t *Tuple5Struct[_, T1, _, T2, _, T3, _, T4, _, T5, _]) Values() (T1, T2, T3, T4, T5) {
return t.value1, t.value2, t.value3, t.value4, t.value5
}