@@ -37,137 +37,137 @@ public extension Database {
37
37
///
38
38
/// :returns: A closure returning a SQL expression to call the function.
39
39
public func create< Z: Value > ( #function: String, deterministic: Bool = false, _ block: ( ) - > Z) -> ( ( ) - > Expression< Z> ) {
40
- return { self . create ( function, deterministic) { _ in return block ( ) } ( [ ] ) }
40
+ return { self . create ( function, 0 , deterministic) { _ in return block ( ) } ( [ ] ) }
41
41
}
42
42
43
43
public func create< Z: Value > ( #function: String, deterministic: Bool = false, _ block: ( ) -> Z ? ) -> ( ( ) -> Expression < Z ? > ) {
44
- return { self . create ( function, deterministic) { _ in return block ( ) } ( [ ] ) }
44
+ return { self . create ( function, 0 , deterministic) { _ in return block ( ) } ( [ ] ) }
45
45
}
46
46
47
47
// MARK: 1 Argument
48
48
49
49
public func create< Z: Value , A: Value > ( #function: String, deterministic: Bool = false, _ block: A -> Z) -> ( Expression < A > -> Expression < Z > ) {
50
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) ) } ( [ $0] ) }
50
+ return { self . create ( function, 1 , deterministic) { block ( asValue ( $0 [ 0 ] ) ) } ( [ $0] ) }
51
51
}
52
52
53
53
public func create< Z: Value , A: Value > ( #function: String, deterministic: Bool = false, _ block: A? -> Z) -> ( Expression < A ? > -> Expression < Z > ) {
54
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) ) } ( [ $0] ) }
54
+ return { self . create ( function, 1 , deterministic) { block ( $0 [ 0 ] . map ( asValue) ) } ( [ $0] ) }
55
55
}
56
56
57
57
public func create< Z: Value , A: Value > ( #function: String, deterministic: Bool = false, _ block: A -> Z? ) -> ( Expression < A > -> Expression < Z ? > ) {
58
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) ) } ( [ $0] ) }
58
+ return { self . create ( function, 1 , deterministic) { block ( asValue ( $0 [ 0 ] ) ) } ( [ $0] ) }
59
59
}
60
60
61
61
public func create< Z: Value , A: Value > ( #function: String, deterministic: Bool = false, _ block: A? -> Z? ) -> ( Expression < A ? > -> Expression < Z ? > ) {
62
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) ) } ( [ $0] ) }
62
+ return { self . create ( function, 1 , deterministic) { block ( $0 [ 0 ] . map ( asValue) ) } ( [ $0] ) }
63
63
}
64
64
65
65
// MARK: 2 Arguments
66
66
67
67
public func create< Z: Value , A: protocol < Value , Expressible > , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A, B) -> Z ) -> ( ( A , Expression < B > ) -> Expression < Z > ) {
68
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
68
+ return { self . create ( function, 2 , deterministic) { block ( asValue ( $0 [ 0 ] ) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
69
69
}
70
70
71
71
public func create< Z: Value , A: protocol < Value , Expressible > , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A? , B) -> Z ) -> ( ( A ? , Expression < B > ) -> Expression < Z > ) {
72
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) , asValue ( $0 [ 1 ] ) ) } ( [ Expression < A ? > ( value: $0) , $1] ) }
72
+ return { self . create ( function, 2 , deterministic) { block ( $0 [ 0 ] . map ( asValue) , asValue ( $0 [ 1 ] ) ) } ( [ Expression < A ? > ( value: $0) , $1] ) }
73
73
}
74
74
75
75
public func create< Z: Value , A: protocol < Value , Expressible > , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A, B? ) -> Z ) -> ( ( A , Expression < B ? > ) -> Expression < Z > ) {
76
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, $1] ) }
76
+ return { self . create ( function, 2 , deterministic) { block ( asValue ( $0 [ 0 ] ) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, $1] ) }
77
77
}
78
78
79
79
public func create< Z: Value , A: protocol < Value , Expressible > , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A? , B? ) -> Z ) -> ( ( A ? , Expression < B ? > ) -> Expression < Z > ) {
80
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) , $0 [ 1 ] . map ( asValue) ) } ( [ Expression < A ? > ( value: $0) , $1] ) }
80
+ return { self . create ( function, 2 , deterministic) { block ( $0 [ 0 ] . map ( asValue) , $0 [ 1 ] . map ( asValue) ) } ( [ Expression < A ? > ( value: $0) , $1] ) }
81
81
}
82
82
83
83
public func create< Z: Value , A: protocol < Value , Expressible > , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A, B) -> Z ? ) -> ( ( A , Expression < B > ) -> Expression < Z ? > ) {
84
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
84
+ return { self . create ( function, 2 , deterministic) { block ( asValue ( $0 [ 0 ] ) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
85
85
}
86
86
87
87
public func create< Z: Value , A: protocol < Value , Expressible > , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A? , B) -> Z ? ) -> ( ( A ? , Expression < B > ) -> Expression < Z ? > ) {
88
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) , asValue ( $0 [ 1 ] ) ) } ( [ Expression < A ? > ( value: $0) , $1] ) }
88
+ return { self . create ( function, 2 , deterministic) { block ( $0 [ 0 ] . map ( asValue) , asValue ( $0 [ 1 ] ) ) } ( [ Expression < A ? > ( value: $0) , $1] ) }
89
89
}
90
90
91
91
public func create< Z: Value , A: protocol < Value , Expressible > , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A, B? ) -> Z ? ) -> ( ( A , Expression < B ? > ) -> Expression < Z ? > ) {
92
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, $1] ) }
92
+ return { self . create ( function, 2 , deterministic) { block ( asValue ( $0 [ 0 ] ) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, $1] ) }
93
93
}
94
94
95
95
public func create< Z: Value , A: protocol < Value , Expressible > , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A? , B? ) -> Z ? ) -> ( ( A ? , Expression < B ? > ) -> Expression < Z ? > ) {
96
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) , $0 [ 1 ] . map ( asValue) ) } ( [ Expression < A ? > ( value: $0) , $1] ) }
96
+ return { self . create ( function, 2 , deterministic) { block ( $0 [ 0 ] . map ( asValue) , $0 [ 1 ] . map ( asValue) ) } ( [ Expression < A ? > ( value: $0) , $1] ) }
97
97
}
98
98
99
99
public func create< Z: Value , A: Value , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A, B) -> Z ) -> ( ( Expression < A > , Expression < B > ) -> Expression < Z > ) {
100
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
100
+ return { self . create ( function, 2 , deterministic) { block ( asValue ( $0 [ 0 ] ) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
101
101
}
102
102
103
103
public func create< Z: Value , A: Value , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A? , B) -> Z ) -> ( ( Expression < A ? > , Expression < B > ) -> Expression < Z > ) {
104
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
104
+ return { self . create ( function, 2 , deterministic) { block ( $0 [ 0 ] . map ( asValue) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
105
105
}
106
106
107
107
public func create< Z: Value , A: Value , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A, B? ) -> Z ) -> ( ( Expression < A > , Expression < B ? > ) -> Expression < Z > ) {
108
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, $1] ) }
108
+ return { self . create ( function, 2 , deterministic) { block ( asValue ( $0 [ 0 ] ) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, $1] ) }
109
109
}
110
110
111
111
public func create< Z: Value , A: Value , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A? , B? ) -> Z ) -> ( ( Expression < A ? > , Expression < B ? > ) -> Expression < Z > ) {
112
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, $1] ) }
112
+ return { self . create ( function, 2 , deterministic) { block ( $0 [ 0 ] . map ( asValue) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, $1] ) }
113
113
}
114
114
115
115
public func create< Z: Value , A: Value , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A, B) -> Z ? ) -> ( ( Expression < A > , Expression < B > ) -> Expression < Z ? > ) {
116
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
116
+ return { self . create ( function, 2 , deterministic) { block ( asValue ( $0 [ 0 ] ) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
117
117
}
118
118
119
119
public func create< Z: Value , A: Value , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A? , B) -> Z ? ) -> ( ( Expression < A ? > , Expression < B > ) -> Expression < Z ? > ) {
120
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
120
+ return { self . create ( function, 2 , deterministic) { block ( $0 [ 0 ] . map ( asValue) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
121
121
}
122
122
123
123
public func create< Z: Value , A: Value , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A, B? ) -> Z ? ) -> ( ( Expression < A > , Expression < B ? > ) -> Expression < Z ? > ) {
124
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, $1] ) }
124
+ return { self . create ( function, 2 , deterministic) { block ( asValue ( $0 [ 0 ] ) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, $1] ) }
125
125
}
126
126
127
127
public func create< Z: Value , A: Value , B: Value > ( #function: String, deterministic: Bool = false, _ block: ( A? , B? ) -> Z ? ) -> ( ( Expression < A ? > , Expression < B ? > ) -> Expression < Z ? > ) {
128
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, $1] ) }
128
+ return { self . create ( function, 2 , deterministic) { block ( $0 [ 0 ] . map ( asValue) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, $1] ) }
129
129
}
130
130
131
131
public func create< Z: Value , A: Value , B: protocol < Value , Expressible > > ( #function: String, deterministic: Bool = false, _ block: ( A, B) -> Z ) -> ( ( Expression < A > , B ) -> Expression < Z > ) {
132
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
132
+ return { self . create ( function, 2 , deterministic) { block ( asValue ( $0 [ 0 ] ) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
133
133
}
134
134
135
135
public func create< Z: Value , A: Value , B: protocol < Value , Expressible > > ( #function: String, deterministic: Bool = false, _ block: ( A? , B) -> Z ) -> ( ( Expression < A ? > , B ) -> Expression < Z > ) {
136
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
136
+ return { self . create ( function, 2 , deterministic) { block ( $0 [ 0 ] . map ( asValue) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
137
137
}
138
138
139
139
public func create< Z: Value , A: Value , B: protocol < Value , Expressible > > ( #function: String, deterministic: Bool = false, _ block: ( A, B? ) -> Z ) -> ( ( Expression < A > , B ? ) -> Expression < Z > ) {
140
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, Expression < B ? > ( value: $1) ] ) }
140
+ return { self . create ( function, 2 , deterministic) { block ( asValue ( $0 [ 0 ] ) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, Expression < B ? > ( value: $1) ] ) }
141
141
}
142
142
143
143
public func create< Z: Value , A: Value , B: protocol < Value , Expressible > > ( #function: String, deterministic: Bool = false, _ block: ( A? , B? ) -> Z ) -> ( ( Expression < A ? > , B ? ) -> Expression < Z > ) {
144
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, Expression < B ? > ( value: $1) ] ) }
144
+ return { self . create ( function, 2 , deterministic) { block ( $0 [ 0 ] . map ( asValue) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, Expression < B ? > ( value: $1) ] ) }
145
145
}
146
146
147
147
public func create< Z: Value , A: Value , B: protocol < Value , Expressible > > ( #function: String, deterministic: Bool = false, _ block: ( A, B) -> Z ? ) -> ( ( Expression < A > , B ) -> Expression < Z ? > ) {
148
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
148
+ return { self . create ( function, 2 , deterministic) { block ( asValue ( $0 [ 0 ] ) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
149
149
}
150
150
151
151
public func create< Z: Value , A: Value , B: protocol < Value , Expressible > > ( #function: String, deterministic: Bool = false, _ block: ( A? , B) -> Z ? ) -> ( ( Expression < A ? > , B ) -> Expression < Z ? > ) {
152
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
152
+ return { self . create ( function, 2 , deterministic) { block ( $0 [ 0 ] . map ( asValue) , asValue ( $0 [ 1 ] ) ) } ( [ $0, $1] ) }
153
153
}
154
154
155
155
public func create< Z: Value , A: Value , B: protocol < Value , Expressible > > ( #function: String, deterministic: Bool = false, _ block: ( A, B? ) -> Z ? ) -> ( ( Expression < A > , B ? ) -> Expression < Z ? > ) {
156
- return { self . create ( function, deterministic) { block ( asValue ( $0 [ 0 ] ) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, Expression < B ? > ( value: $1) ] ) }
156
+ return { self . create ( function, 2 , deterministic) { block ( asValue ( $0 [ 0 ] ) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, Expression < B ? > ( value: $1) ] ) }
157
157
}
158
158
159
159
public func create< Z: Value , A: Value , B: protocol < Value , Expressible > > ( #function: String, deterministic: Bool = false, _ block: ( A? , B? ) -> Z ? ) -> ( ( Expression < A ? > , B ? ) -> Expression < Z ? > ) {
160
- return { self . create ( function, deterministic) { block ( $0 [ 0 ] . map ( asValue) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, Expression < B ? > ( value: $1) ] ) }
160
+ return { self . create ( function, 2 , deterministic) { block ( $0 [ 0 ] . map ( asValue) , $0 [ 1 ] . map ( asValue) ) } ( [ $0, Expression < B ? > ( value: $1) ] ) }
161
161
}
162
162
163
163
// MARK: -
164
164
165
- private func create< Z: Value > ( function: String , _ deterministic: Bool , _ block: [ Binding ? ] -> Z ) -> ( [ Expressible ] -> Expression < Z > ) {
166
- return { Expression < Z > ( self . create ( function, deterministic) { ( arguments: [ Binding ? ] ) -> Z ? in block ( arguments) } ( $0) ) }
165
+ private func create< Z: Value > ( function: String , _ argc : Int , _ deterministic: Bool , _ block: [ Binding ? ] -> Z ) -> ( [ Expressible ] -> Expression < Z > ) {
166
+ return { Expression < Z > ( self . create ( function, argc , deterministic) { ( arguments: [ Binding ? ] ) -> Z ? in block ( arguments) } ( $0) ) }
167
167
}
168
168
169
- private func create< Z: Value > ( function: String , _ deterministic: Bool , _ block: [ Binding ? ] -> Z ? ) -> ( [ Expressible ] -> Expression < Z ? > ) {
170
- create ( function: function, deterministic: deterministic) { block ( $0) ? . datatypeValue }
169
+ private func create< Z: Value > ( function: String , _ argc : Int , _ deterministic: Bool , _ block: [ Binding ? ] -> Z ? ) -> ( [ Expressible ] -> Expression < Z ? > ) {
170
+ create ( function: function, argc : argc , deterministic: deterministic) { block ( $0) ? . datatypeValue }
171
171
return { arguments in wrap ( quote ( identifier: function) , Expression< Z> . join( " , " , arguments) ) }
172
172
}
173
173
0 commit comments