Skip to content

Commit 861ff28

Browse files
authored
Merge pull request #891 from ottosuess/master
fix xcode-10.2 issues
2 parents ed8f603 + 1a34caf commit 861ff28

File tree

4 files changed

+296
-230
lines changed

4 files changed

+296
-230
lines changed

Sources/SQLite/Helpers.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,6 @@ extension String {
9898

9999
}
100100

101-
func infix<T>(_ lhs: Expressible, _ rhs: Expressible, wrap: Bool = true, function: String = #function) -> Expression<T> {
102-
return function.infix(lhs, rhs, wrap: wrap)
103-
}
104-
105-
func wrap<T>(_ expression: Expressible, function: String = #function) -> Expression<T> {
106-
return function.wrap(expression)
107-
}
108-
109-
func wrap<T>(_ expressions: [Expressible], function: String = #function) -> Expression<T> {
110-
return function.wrap(", ".join(expressions))
111-
}
112-
113101
func transcode(_ literal: Binding?) -> String {
114102
guard let literal = literal else { return "NULL" }
115103

Sources/SQLite/Typed/AggregateFunctions.swift

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@
2222
// THE SOFTWARE.
2323
//
2424

25+
private enum Function: String {
26+
case count
27+
case max
28+
case min
29+
case avg
30+
case sum
31+
case total
32+
33+
func wrap<T>(_ expression: Expressible) -> Expression<T> {
34+
return self.rawValue.wrap(expression)
35+
}
36+
}
37+
2538
extension ExpressionType where UnderlyingType : Value {
2639

2740
/// Builds a copy of the expression prefixed with the `DISTINCT` keyword.
@@ -48,7 +61,7 @@ extension ExpressionType where UnderlyingType : Value {
4861
/// - Returns: A copy of the expression wrapped with the `count` aggregate
4962
/// function.
5063
public var count: Expression<Int> {
51-
return wrap(self)
64+
return Function.count.wrap(self)
5265
}
5366

5467
}
@@ -79,7 +92,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr
7992
/// - Returns: A copy of the expression wrapped with the `count` aggregate
8093
/// function.
8194
public var count: Expression<Int> {
82-
return wrap(self)
95+
return Function.count.wrap(self)
8396
}
8497

8598
}
@@ -96,7 +109,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype :
96109
/// - Returns: A copy of the expression wrapped with the `max` aggregate
97110
/// function.
98111
public var max: Expression<UnderlyingType?> {
99-
return wrap(self)
112+
return Function.max.wrap(self)
100113
}
101114

102115
/// Builds a copy of the expression wrapped with the `min` aggregate
@@ -109,7 +122,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype :
109122
/// - Returns: A copy of the expression wrapped with the `min` aggregate
110123
/// function.
111124
public var min: Expression<UnderlyingType?> {
112-
return wrap(self)
125+
return Function.min.wrap(self)
113126
}
114127

115128
}
@@ -126,7 +139,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr
126139
/// - Returns: A copy of the expression wrapped with the `max` aggregate
127140
/// function.
128141
public var max: Expression<UnderlyingType> {
129-
return wrap(self)
142+
return Function.max.wrap(self)
130143
}
131144

132145
/// Builds a copy of the expression wrapped with the `min` aggregate
@@ -139,7 +152,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr
139152
/// - Returns: A copy of the expression wrapped with the `min` aggregate
140153
/// function.
141154
public var min: Expression<UnderlyingType> {
142-
return wrap(self)
155+
return Function.min.wrap(self)
143156
}
144157

145158
}
@@ -156,7 +169,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype :
156169
/// - Returns: A copy of the expression wrapped with the `min` aggregate
157170
/// function.
158171
public var average: Expression<Double?> {
159-
return "avg".wrap(self)
172+
return Function.avg.wrap(self)
160173
}
161174

162175
/// Builds a copy of the expression wrapped with the `sum` aggregate
@@ -169,7 +182,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype :
169182
/// - Returns: A copy of the expression wrapped with the `min` aggregate
170183
/// function.
171184
public var sum: Expression<UnderlyingType?> {
172-
return wrap(self)
185+
return Function.sum.wrap(self)
173186
}
174187

175188
/// Builds a copy of the expression wrapped with the `total` aggregate
@@ -182,7 +195,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype :
182195
/// - Returns: A copy of the expression wrapped with the `min` aggregate
183196
/// function.
184197
public var total: Expression<Double> {
185-
return wrap(self)
198+
return Function.total.wrap(self)
186199
}
187200

188201
}
@@ -199,7 +212,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr
199212
/// - Returns: A copy of the expression wrapped with the `min` aggregate
200213
/// function.
201214
public var average: Expression<Double?> {
202-
return "avg".wrap(self)
215+
return Function.avg.wrap(self)
203216
}
204217

205218
/// Builds a copy of the expression wrapped with the `sum` aggregate
@@ -212,7 +225,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr
212225
/// - Returns: A copy of the expression wrapped with the `min` aggregate
213226
/// function.
214227
public var sum: Expression<UnderlyingType> {
215-
return wrap(self)
228+
return Function.sum.wrap(self)
216229
}
217230

218231
/// Builds a copy of the expression wrapped with the `total` aggregate
@@ -225,15 +238,15 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr
225238
/// - Returns: A copy of the expression wrapped with the `min` aggregate
226239
/// function.
227240
public var total: Expression<Double> {
228-
return wrap(self)
241+
return Function.total.wrap(self)
229242
}
230243

231244
}
232245

233246
extension ExpressionType where UnderlyingType == Int {
234247

235248
static func count(_ star: Star) -> Expression<UnderlyingType> {
236-
return wrap(star(nil, nil))
249+
return Function.count.wrap(star(nil, nil))
237250
}
238251

239252
}

0 commit comments

Comments
 (0)