Skip to content

Commit d7b9146

Browse files
committed
Fix using aggregate functions with Swift 5.
In Swift 5, the value of `#function` for e.g. `func count(_:)` has changed from `count` to `count(_:)` (see swiftlang/swift#19062), causing `wrap` to produce invalid SQL. We fix this by only using the part of `#function` preceding the first opening parenthesis.
1 parent 0d81e34 commit d7b9146

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/SQLite/Helpers.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ extension String {
9999
}
100100

101101
func infix<T>(_ lhs: Expressible, _ rhs: Expressible, wrap: Bool = true, function: String = #function) -> Expression<T> {
102-
return function.infix(lhs, rhs, wrap: wrap)
102+
return function.components(separatedBy: "(")[0].infix(lhs, rhs, wrap: wrap)
103103
}
104104

105105
func wrap<T>(_ expression: Expressible, function: String = #function) -> Expression<T> {
106-
return function.wrap(expression)
106+
return function.components(separatedBy: "(")[0].wrap(expression)
107107
}
108108

109109
func wrap<T>(_ expressions: [Expressible], function: String = #function) -> Expression<T> {
110-
return function.wrap(", ".join(expressions))
110+
return function.components(separatedBy: "(")[0].wrap(", ".join(expressions))
111111
}
112112

113113
func transcode(_ literal: Binding?) -> String {

0 commit comments

Comments
 (0)