Skip to content

Commit

Permalink
Fix SQL statement generation problem on Xcode 10.2
Browse files Browse the repository at this point in the history
Referenced SQLite.swift issue  **[stephencelis#888](stephencelis#888
  • Loading branch information
codepgq committed Apr 4, 2019
1 parent 861ff28 commit b00bdd7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Sources/SQLite/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,40 @@ extension String {
func wrap<T>(_ expressions: [Expressible]) -> Expression<T> {
return wrap(", ".join(expressions))
}

private func trimName(_ function: String) -> String {
return function.components(separatedBy: "(").first ?? function
}

func infix<T>(_ lhs: Expressible, _ rhs: Expressible, wrap: Bool = true, function: String = #function) -> Expression<T> {
return trimName(function).infix(lhs, rhs, wrap: wrap)
}

func wrap<T>(_ expression: Expressible, function: String = #function) -> Expression<T> {
return trimName(function).wrap(expression)
}

func wrap<T>(_ expressions: [Expressible], function: String = #function) -> Expression<T> {
return trimName(function).wrap(", ".join(expressions))
}

}

func infix<T>(_ lhs: Expressible, _ rhs: Expressible, wrap: Bool = true, function: String = #function) -> Expression<T> {
var funcStr = function
if let range = funcStr.range(of: "(_:_:)") {
funcStr.removeSubrange(range)
}

return funcStr.infix(lhs, rhs, wrap: wrap)
}

func wrap<T>(_ expression: Expressible, function: String = #function) -> Expression<T> {
return function.wrap(expression)
}

func wrap<T>(_ expressions: [Expressible], function: String = #function) -> Expression<T> {
return function.wrap(", ".join(expressions))

}

Expand Down

0 comments on commit b00bdd7

Please sign in to comment.