From c96a5da4ef8c9ccec7bfac254b56ae17199097f3 Mon Sep 17 00:00:00 2001 From: Otto Suess Date: Tue, 26 Mar 2019 12:53:22 +0100 Subject: [PATCH 1/3] fix xcode-10.2 issues --- Sources/SQLite/Helpers.swift | 12 - Sources/SQLite/Typed/AggregateFunctions.swift | 22 +- Sources/SQLite/Typed/CoreFunctions.swift | 40 +-- Sources/SQLite/Typed/Operators.swift | 232 +++++++++--------- 4 files changed, 147 insertions(+), 159 deletions(-) diff --git a/Sources/SQLite/Helpers.swift b/Sources/SQLite/Helpers.swift index ac831667..115ea5c6 100644 --- a/Sources/SQLite/Helpers.swift +++ b/Sources/SQLite/Helpers.swift @@ -98,18 +98,6 @@ extension String { } -func infix(_ lhs: Expressible, _ rhs: Expressible, wrap: Bool = true, function: String = #function) -> Expression { - return function.infix(lhs, rhs, wrap: wrap) -} - -func wrap(_ expression: Expressible, function: String = #function) -> Expression { - return function.wrap(expression) -} - -func wrap(_ expressions: [Expressible], function: String = #function) -> Expression { - return function.wrap(", ".join(expressions)) -} - func transcode(_ literal: Binding?) -> String { guard let literal = literal else { return "NULL" } diff --git a/Sources/SQLite/Typed/AggregateFunctions.swift b/Sources/SQLite/Typed/AggregateFunctions.swift index 249bbe60..bb1157fe 100644 --- a/Sources/SQLite/Typed/AggregateFunctions.swift +++ b/Sources/SQLite/Typed/AggregateFunctions.swift @@ -48,7 +48,7 @@ extension ExpressionType where UnderlyingType : Value { /// - Returns: A copy of the expression wrapped with the `count` aggregate /// function. public var count: Expression { - return wrap(self) + return "count".wrap(self) } } @@ -79,7 +79,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `count` aggregate /// function. public var count: Expression { - return wrap(self) + return "count".wrap(self) } } @@ -96,7 +96,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `max` aggregate /// function. public var max: Expression { - return wrap(self) + return "max".wrap(self) } /// Builds a copy of the expression wrapped with the `min` aggregate @@ -109,7 +109,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var min: Expression { - return wrap(self) + return "min".wrap(self) } } @@ -126,7 +126,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `max` aggregate /// function. public var max: Expression { - return wrap(self) + return "max".wrap(self) } /// Builds a copy of the expression wrapped with the `min` aggregate @@ -139,7 +139,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var min: Expression { - return wrap(self) + return "min".wrap(self) } } @@ -169,7 +169,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var sum: Expression { - return wrap(self) + return "sum".wrap(self) } /// Builds a copy of the expression wrapped with the `total` aggregate @@ -182,7 +182,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var total: Expression { - return wrap(self) + return "total".wrap(self) } } @@ -212,7 +212,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var sum: Expression { - return wrap(self) + return "sum".wrap(self) } /// Builds a copy of the expression wrapped with the `total` aggregate @@ -225,7 +225,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var total: Expression { - return wrap(self) + return "total".wrap(self) } } @@ -233,7 +233,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr extension ExpressionType where UnderlyingType == Int { static func count(_ star: Star) -> Expression { - return wrap(star(nil, nil)) + return "count".wrap(star(nil, nil)) } } diff --git a/Sources/SQLite/Typed/CoreFunctions.swift b/Sources/SQLite/Typed/CoreFunctions.swift index d7995b95..b7b53c71 100644 --- a/Sources/SQLite/Typed/CoreFunctions.swift +++ b/Sources/SQLite/Typed/CoreFunctions.swift @@ -68,9 +68,9 @@ extension ExpressionType where UnderlyingType == Double { /// - Returns: A copy of the expression wrapped with the `round` function. public func round(_ precision: Int? = nil) -> Expression { guard let precision = precision else { - return wrap([self]) + return "round".wrap([self]) } - return wrap([self, Int(precision)]) + return "round".wrap([self, Int(precision)]) } } @@ -88,9 +88,9 @@ extension ExpressionType where UnderlyingType == Double? { /// - Returns: A copy of the expression wrapped with the `round` function. public func round(_ precision: Int? = nil) -> Expression { guard let precision = precision else { - return wrap(self) + return "round".wrap(self) } - return wrap([self, Int(precision)]) + return "round".wrap([self, Int(precision)]) } } @@ -143,7 +143,7 @@ extension ExpressionType where UnderlyingType == Data { /// /// - Returns: A copy of the expression wrapped with the `length` function. public var length: Expression { - return wrap(self) + return "length".wrap(self) } } @@ -158,7 +158,7 @@ extension ExpressionType where UnderlyingType == Data? { /// /// - Returns: A copy of the expression wrapped with the `length` function. public var length: Expression { - return wrap(self) + return "length".wrap(self) } } @@ -173,7 +173,7 @@ extension ExpressionType where UnderlyingType == String { /// /// - Returns: A copy of the expression wrapped with the `length` function. public var length: Expression { - return wrap(self) + return "length".wrap(self) } /// Builds a copy of the expression wrapped with the `lower` function. @@ -317,9 +317,9 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression wrapped with the `ltrim` function. public func ltrim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return wrap(self) + return "ltrim".wrap(self) } - return wrap([self, String(characters)]) + return "ltrim".wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `rtrim` function. @@ -335,9 +335,9 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression wrapped with the `rtrim` function. public func rtrim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return wrap(self) + return "rtrim".wrap(self) } - return wrap([self, String(characters)]) + return "rtrim".wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `trim` function. @@ -353,9 +353,9 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression wrapped with the `trim` function. public func trim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return wrap([self]) + return "trim".wrap([self]) } - return wrap([self, String(characters)]) + return "trim".wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `replace` function. @@ -398,7 +398,7 @@ extension ExpressionType where UnderlyingType == String? { /// /// - Returns: A copy of the expression wrapped with the `length` function. public var length: Expression { - return wrap(self) + return "length".wrap(self) } /// Builds a copy of the expression wrapped with the `lower` function. @@ -542,9 +542,9 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression wrapped with the `ltrim` function. public func ltrim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return wrap(self) + return "ltrim".wrap(self) } - return wrap([self, String(characters)]) + return "ltrim".wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `rtrim` function. @@ -560,9 +560,9 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression wrapped with the `rtrim` function. public func rtrim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return wrap(self) + return "rtrim".wrap(self) } - return wrap([self, String(characters)]) + return "rtrim".wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `trim` function. @@ -578,9 +578,9 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression wrapped with the `trim` function. public func trim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return wrap(self) + return "trim".wrap(self) } - return wrap([self, String(characters)]) + return "trim".wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `replace` function. diff --git a/Sources/SQLite/Typed/Operators.swift b/Sources/SQLite/Typed/Operators.swift index d97e52b9..5f8be14b 100644 --- a/Sources/SQLite/Typed/Operators.swift +++ b/Sources/SQLite/Typed/Operators.swift @@ -53,237 +53,237 @@ public func +(lhs: String, rhs: Expression) -> Expression { // MARK: - public func +(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "+".infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "+".infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "+".infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "+".infix(lhs, rhs) } public func +(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "+".infix(lhs, rhs) } public func +(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "+".infix(lhs, rhs) } public func +(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "+".infix(lhs, rhs) } public func +(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "+".infix(lhs, rhs) } public func -(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "-".infix(lhs, rhs) } public func -(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "-".infix(lhs, rhs) } public func -(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "-".infix(lhs, rhs) } public func -(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "-".infix(lhs, rhs) } public func -(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "-".infix(lhs, rhs) } public func -(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "-".infix(lhs, rhs) } public func -(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "-".infix(lhs, rhs) } public func -(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "-".infix(lhs, rhs) } public func *(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "*".infix(lhs, rhs) } public func *(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "*".infix(lhs, rhs) } public func *(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "*".infix(lhs, rhs) } public func *(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "*".infix(lhs, rhs) } public func *(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "*".infix(lhs, rhs) } public func *(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "*".infix(lhs, rhs) } public func *(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "*".infix(lhs, rhs) } public func *(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "*".infix(lhs, rhs) } public func /(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "/".infix(lhs, rhs) } public func /(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "/".infix(lhs, rhs) } public func /(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "/".infix(lhs, rhs) } public func /(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "/".infix(lhs, rhs) } public func /(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "/".infix(lhs, rhs) } public func /(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "/".infix(lhs, rhs) } public func /(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "/".infix(lhs, rhs) } public func /(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return infix(lhs, rhs) + return "/".infix(lhs, rhs) } public prefix func -(rhs: Expression) -> Expression where V.Datatype : Number { - return wrap(rhs) + return "-".wrap(rhs) } public prefix func -(rhs: Expression) -> Expression where V.Datatype : Number { - return wrap(rhs) + return "-".wrap(rhs) } // MARK: - public func %(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "%".infix(lhs, rhs) } public func %(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "%".infix(lhs, rhs) } public func %(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "%".infix(lhs, rhs) } public func %(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "%".infix(lhs, rhs) } public func %(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "%".infix(lhs, rhs) } public func %(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "%".infix(lhs, rhs) } public func %(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "%".infix(lhs, rhs) } public func %(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "%".infix(lhs, rhs) } public func <<(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "<<".infix(lhs, rhs) } public func <<(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "<<".infix(lhs, rhs) } public func <<(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "<<".infix(lhs, rhs) } public func <<(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "<<".infix(lhs, rhs) } public func <<(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "<<".infix(lhs, rhs) } public func <<(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "<<".infix(lhs, rhs) } public func <<(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "<<".infix(lhs, rhs) } public func <<(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "<<".infix(lhs, rhs) } public func >>(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return ">>".infix(lhs, rhs) } public func >>(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return ">>".infix(lhs, rhs) } public func >>(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return ">>".infix(lhs, rhs) } public func >>(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return ">>".infix(lhs, rhs) } public func >>(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return ">>".infix(lhs, rhs) } public func >>(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return ">>".infix(lhs, rhs) } public func >>(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return ">>".infix(lhs, rhs) } public func >>(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return ">>".infix(lhs, rhs) } public func &(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "&".infix(lhs, rhs) } public func &(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "&".infix(lhs, rhs) } public func &(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "&".infix(lhs, rhs) } public func &(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "&".infix(lhs, rhs) } public func &(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "&".infix(lhs, rhs) } public func &(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "&".infix(lhs, rhs) } public func &(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "&".infix(lhs, rhs) } public func &(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "&".infix(lhs, rhs) } public func |(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "|".infix(lhs, rhs) } public func |(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "|".infix(lhs, rhs) } public func |(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "|".infix(lhs, rhs) } public func |(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "|".infix(lhs, rhs) } public func |(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "|".infix(lhs, rhs) } public func |(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "|".infix(lhs, rhs) } public func |(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "|".infix(lhs, rhs) } public func |(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return infix(lhs, rhs) + return "|".infix(lhs, rhs) } public func ^(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { @@ -312,10 +312,10 @@ public func ^(lhs: V, rhs: Expression) -> Expression where V. } public prefix func ~(rhs: Expression) -> Expression where V.Datatype == Int64 { - return wrap(rhs) + return "~".wrap(rhs) } public prefix func ~(rhs: Expression) -> Expression where V.Datatype == Int64 { - return wrap(rhs) + return "~".wrap(rhs) } // MARK: - @@ -348,130 +348,130 @@ public func ==(lhs: V?, rhs: Expression) -> Expression whe } public func !=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return infix(lhs, rhs) + return "!=".infix(lhs, rhs) } public func !=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return infix(lhs, rhs) + return "!=".infix(lhs, rhs) } public func !=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return infix(lhs, rhs) + return "!=".infix(lhs, rhs) } public func !=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return infix(lhs, rhs) + return "!=".infix(lhs, rhs) } public func !=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Equatable { - return infix(lhs, rhs) + return "!=".infix(lhs, rhs) } public func !=(lhs: Expression, rhs: V?) -> Expression where V.Datatype : Equatable { guard let rhs = rhs else { return "IS NOT".infix(lhs, Expression(value: nil)) } - return infix(lhs, rhs) + return "!=".infix(lhs, rhs) } public func !=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Equatable { - return infix(lhs, rhs) + return "!=".infix(lhs, rhs) } public func !=(lhs: V?, rhs: Expression) -> Expression where V.Datatype : Equatable { guard let lhs = lhs else { return "IS NOT".infix(Expression(value: nil), rhs) } - return infix(lhs, rhs) + return "!=".infix(lhs, rhs) } public func >(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">".infix(lhs, rhs) } public func >(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">".infix(lhs, rhs) } public func >(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">".infix(lhs, rhs) } public func >(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">".infix(lhs, rhs) } public func >(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">".infix(lhs, rhs) } public func >(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">".infix(lhs, rhs) } public func >(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">".infix(lhs, rhs) } public func >(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">".infix(lhs, rhs) } public func >=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">=".infix(lhs, rhs) } public func >=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">=".infix(lhs, rhs) } public func >=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">=".infix(lhs, rhs) } public func >=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">=".infix(lhs, rhs) } public func >=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">=".infix(lhs, rhs) } public func >=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">=".infix(lhs, rhs) } public func >=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">=".infix(lhs, rhs) } public func >=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return ">=".infix(lhs, rhs) } public func <(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<".infix(lhs, rhs) } public func <(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<".infix(lhs, rhs) } public func <(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<".infix(lhs, rhs) } public func <(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<".infix(lhs, rhs) } public func <(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<".infix(lhs, rhs) } public func <(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<".infix(lhs, rhs) } public func <(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<".infix(lhs, rhs) } public func <(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<".infix(lhs, rhs) } public func <=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<=".infix(lhs, rhs) } public func <=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<=".infix(lhs, rhs) } public func <=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<=".infix(lhs, rhs) } public func <=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<=".infix(lhs, rhs) } public func <=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<=".infix(lhs, rhs) } public func <=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<=".infix(lhs, rhs) } public func <=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<=".infix(lhs, rhs) } public func <=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return infix(lhs, rhs) + return "<=".infix(lhs, rhs) } public func ~=(lhs: ClosedRange, rhs: Expression) -> Expression where V.Datatype : Comparable & Value { From c5be72bac4a022448b92d75a8970e41c6254b21f Mon Sep 17 00:00:00 2001 From: Yehor Popovych Date: Tue, 26 Mar 2019 17:54:28 +0200 Subject: [PATCH 2/3] Strings to enum constants --- Sources/SQLite/Typed/AggregateFunctions.swift | 39 ++- Sources/SQLite/Typed/CoreFunctions.swift | 140 +++++--- Sources/SQLite/Typed/Operators.swift | 331 ++++++++++-------- 3 files changed, 294 insertions(+), 216 deletions(-) diff --git a/Sources/SQLite/Typed/AggregateFunctions.swift b/Sources/SQLite/Typed/AggregateFunctions.swift index bb1157fe..056d617e 100644 --- a/Sources/SQLite/Typed/AggregateFunctions.swift +++ b/Sources/SQLite/Typed/AggregateFunctions.swift @@ -22,6 +22,19 @@ // THE SOFTWARE. // +private enum Functions: String { + case count + case max + case min + case avg + case sum + case total + + func wrap(_ expression: Expressible) -> Expression { + return self.rawValue.wrap(expression) + } +} + extension ExpressionType where UnderlyingType : Value { /// Builds a copy of the expression prefixed with the `DISTINCT` keyword. @@ -48,7 +61,7 @@ extension ExpressionType where UnderlyingType : Value { /// - Returns: A copy of the expression wrapped with the `count` aggregate /// function. public var count: Expression { - return "count".wrap(self) + return Functions.count.wrap(self) } } @@ -79,7 +92,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `count` aggregate /// function. public var count: Expression { - return "count".wrap(self) + return Functions.count.wrap(self) } } @@ -96,7 +109,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `max` aggregate /// function. public var max: Expression { - return "max".wrap(self) + return Functions.max.wrap(self) } /// Builds a copy of the expression wrapped with the `min` aggregate @@ -109,7 +122,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var min: Expression { - return "min".wrap(self) + return Functions.min.wrap(self) } } @@ -126,7 +139,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `max` aggregate /// function. public var max: Expression { - return "max".wrap(self) + return Functions.max.wrap(self) } /// Builds a copy of the expression wrapped with the `min` aggregate @@ -139,7 +152,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var min: Expression { - return "min".wrap(self) + return Functions.min.wrap(self) } } @@ -156,7 +169,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var average: Expression { - return "avg".wrap(self) + return Functions.avg.wrap(self) } /// Builds a copy of the expression wrapped with the `sum` aggregate @@ -169,7 +182,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var sum: Expression { - return "sum".wrap(self) + return Functions.sum.wrap(self) } /// Builds a copy of the expression wrapped with the `total` aggregate @@ -182,7 +195,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var total: Expression { - return "total".wrap(self) + return Functions.total.wrap(self) } } @@ -199,7 +212,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var average: Expression { - return "avg".wrap(self) + return Functions.avg.wrap(self) } /// Builds a copy of the expression wrapped with the `sum` aggregate @@ -212,7 +225,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var sum: Expression { - return "sum".wrap(self) + return Functions.sum.wrap(self) } /// Builds a copy of the expression wrapped with the `total` aggregate @@ -225,7 +238,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var total: Expression { - return "total".wrap(self) + return Functions.total.wrap(self) } } @@ -233,7 +246,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr extension ExpressionType where UnderlyingType == Int { static func count(_ star: Star) -> Expression { - return "count".wrap(star(nil, nil)) + return Functions.count.wrap(star(nil, nil)) } } diff --git a/Sources/SQLite/Typed/CoreFunctions.swift b/Sources/SQLite/Typed/CoreFunctions.swift index b7b53c71..420110ae 100644 --- a/Sources/SQLite/Typed/CoreFunctions.swift +++ b/Sources/SQLite/Typed/CoreFunctions.swift @@ -24,6 +24,40 @@ import Foundation +private enum Functions: String { + case abs + case round + case random + case randomblob + case zeroblob + case length + case lower + case upper + case ltrim + case rtrim + case trim + case replace + case substr + case LIKE + case IN + case GLOB + case MATCH + case REGEXP + case COLLATE + case ifnull + + func infix(_ lhs: Expressible, _ rhs: Expressible, wrap: Bool = true) -> Expression { + return self.rawValue.infix(lhs, rhs, wrap: wrap) + } + + func wrap(_ expression: Expressible) -> Expression { + return self.rawValue.wrap(expression) + } + + func wrap(_ expressions: [Expressible]) -> Expression { + return self.rawValue.wrap(", ".join(expressions)) + } +} extension ExpressionType where UnderlyingType : Number { @@ -35,7 +69,7 @@ extension ExpressionType where UnderlyingType : Number { /// /// - Returns: A copy of the expression wrapped with the `abs` function. public var absoluteValue : Expression { - return "abs".wrap(self) + return Functions.abs.wrap(self) } } @@ -50,7 +84,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// /// - Returns: A copy of the expression wrapped with the `abs` function. public var absoluteValue : Expression { - return "abs".wrap(self) + return Functions.abs.wrap(self) } } @@ -68,9 +102,9 @@ extension ExpressionType where UnderlyingType == Double { /// - Returns: A copy of the expression wrapped with the `round` function. public func round(_ precision: Int? = nil) -> Expression { guard let precision = precision else { - return "round".wrap([self]) + return Functions.round.wrap([self]) } - return "round".wrap([self, Int(precision)]) + return Functions.round.wrap([self, Int(precision)]) } } @@ -88,9 +122,9 @@ extension ExpressionType where UnderlyingType == Double? { /// - Returns: A copy of the expression wrapped with the `round` function. public func round(_ precision: Int? = nil) -> Expression { guard let precision = precision else { - return "round".wrap(self) + return Functions.round.wrap(self) } - return "round".wrap([self, Int(precision)]) + return Functions.round.wrap([self, Int(precision)]) } } @@ -104,7 +138,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype = /// /// - Returns: An expression calling the `random` function. public static func random() -> Expression { - return "random".wrap([]) + return Functions.random.wrap([]) } } @@ -120,7 +154,7 @@ extension ExpressionType where UnderlyingType == Data { /// /// - Returns: An expression calling the `randomblob` function. public static func random(_ length: Int) -> Expression { - return "randomblob".wrap([]) + return Functions.randomblob.wrap([]) } /// Builds an expression representing the `zeroblob` function. @@ -132,7 +166,7 @@ extension ExpressionType where UnderlyingType == Data { /// /// - Returns: An expression calling the `zeroblob` function. public static func allZeros(_ length: Int) -> Expression { - return "zeroblob".wrap([]) + return Functions.zeroblob.wrap([]) } /// Builds a copy of the expression wrapped with the `length` function. @@ -143,7 +177,7 @@ extension ExpressionType where UnderlyingType == Data { /// /// - Returns: A copy of the expression wrapped with the `length` function. public var length: Expression { - return "length".wrap(self) + return Functions.length.wrap(self) } } @@ -158,7 +192,7 @@ extension ExpressionType where UnderlyingType == Data? { /// /// - Returns: A copy of the expression wrapped with the `length` function. public var length: Expression { - return "length".wrap(self) + return Functions.length.wrap(self) } } @@ -173,7 +207,7 @@ extension ExpressionType where UnderlyingType == String { /// /// - Returns: A copy of the expression wrapped with the `length` function. public var length: Expression { - return "length".wrap(self) + return Functions.length.wrap(self) } /// Builds a copy of the expression wrapped with the `lower` function. @@ -184,7 +218,7 @@ extension ExpressionType where UnderlyingType == String { /// /// - Returns: A copy of the expression wrapped with the `lower` function. public var lowercaseString: Expression { - return "lower".wrap(self) + return Functions.lower.wrap(self) } /// Builds a copy of the expression wrapped with the `upper` function. @@ -195,7 +229,7 @@ extension ExpressionType where UnderlyingType == String { /// /// - Returns: A copy of the expression wrapped with the `upper` function. public var uppercaseString: Expression { - return "upper".wrap(self) + return Functions.upper.wrap(self) } /// Builds a copy of the expression appended with a `LIKE` query against the @@ -242,9 +276,9 @@ extension ExpressionType where UnderlyingType == String { /// the given pattern. public func like(_ pattern: Expression, escape character: Character? = nil) -> Expression { guard let character = character else { - return "LIKE".infix(self, pattern) + return Functions.LIKE.infix(self, pattern) } - let like: Expression = "LIKE".infix(self, pattern, wrap: false) + let like: Expression = Functions.LIKE.infix(self, pattern, wrap: false) return Expression("(\(like.template) ESCAPE ?)", like.bindings + [String(character)]) } @@ -260,7 +294,7 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression appended with a `GLOB` query against /// the given pattern. public func glob(_ pattern: String) -> Expression { - return "GLOB".infix(self, pattern) + return Functions.GLOB.infix(self, pattern) } /// Builds a copy of the expression appended with a `MATCH` query against @@ -275,7 +309,7 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression appended with a `MATCH` query /// against the given pattern. public func match(_ pattern: String) -> Expression { - return "MATCH".infix(self, pattern) + return Functions.MATCH.infix(self, pattern) } /// Builds a copy of the expression appended with a `REGEXP` query against @@ -286,7 +320,7 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression appended with a `REGEXP` query /// against the given pattern. public func regexp(_ pattern: String) -> Expression { - return "REGEXP".infix(self, pattern) + return Functions.REGEXP.infix(self, pattern) } /// Builds a copy of the expression appended with a `COLLATE` clause with @@ -301,7 +335,7 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression appended with a `COLLATE` clause /// with the given sequence. public func collate(_ collation: Collation) -> Expression { - return "COLLATE".infix(self, collation) + return Functions.COLLATE.infix(self, collation) } /// Builds a copy of the expression wrapped with the `ltrim` function. @@ -317,9 +351,9 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression wrapped with the `ltrim` function. public func ltrim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return "ltrim".wrap(self) + return Functions.ltrim.wrap(self) } - return "ltrim".wrap([self, String(characters)]) + return Functions.ltrim.wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `rtrim` function. @@ -335,9 +369,9 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression wrapped with the `rtrim` function. public func rtrim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return "rtrim".wrap(self) + return Functions.rtrim.wrap(self) } - return "rtrim".wrap([self, String(characters)]) + return Functions.rtrim.wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `trim` function. @@ -353,9 +387,9 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression wrapped with the `trim` function. public func trim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return "trim".wrap([self]) + return Functions.trim.wrap([self]) } - return "trim".wrap([self, String(characters)]) + return Functions.trim.wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `replace` function. @@ -372,14 +406,14 @@ extension ExpressionType where UnderlyingType == String { /// /// - Returns: A copy of the expression wrapped with the `replace` function. public func replace(_ pattern: String, with replacement: String) -> Expression { - return "replace".wrap([self, pattern, replacement]) + return Functions.replace.wrap([self, pattern, replacement]) } public func substring(_ location: Int, length: Int? = nil) -> Expression { guard let length = length else { - return "substr".wrap([self, location]) + return Functions.substr.wrap([self, location]) } - return "substr".wrap([self, location, length]) + return Functions.substr.wrap([self, location, length]) } public subscript(range: Range) -> Expression { @@ -398,7 +432,7 @@ extension ExpressionType where UnderlyingType == String? { /// /// - Returns: A copy of the expression wrapped with the `length` function. public var length: Expression { - return "length".wrap(self) + return Functions.length.wrap(self) } /// Builds a copy of the expression wrapped with the `lower` function. @@ -409,7 +443,7 @@ extension ExpressionType where UnderlyingType == String? { /// /// - Returns: A copy of the expression wrapped with the `lower` function. public var lowercaseString: Expression { - return "lower".wrap(self) + return Functions.lower.wrap(self) } /// Builds a copy of the expression wrapped with the `upper` function. @@ -420,7 +454,7 @@ extension ExpressionType where UnderlyingType == String? { /// /// - Returns: A copy of the expression wrapped with the `upper` function. public var uppercaseString: Expression { - return "upper".wrap(self) + return Functions.upper.wrap(self) } /// Builds a copy of the expression appended with a `LIKE` query against the @@ -443,7 +477,7 @@ extension ExpressionType where UnderlyingType == String? { /// the given pattern. public func like(_ pattern: String, escape character: Character? = nil) -> Expression { guard let character = character else { - return "LIKE".infix(self, pattern) + return Functions.LIKE.infix(self, pattern) } return Expression("(\(template) LIKE ? ESCAPE ?)", bindings + [pattern, String(character)]) } @@ -467,7 +501,7 @@ extension ExpressionType where UnderlyingType == String? { /// the given pattern. public func like(_ pattern: Expression, escape character: Character? = nil) -> Expression { guard let character = character else { - return "LIKE".infix(self, pattern) + return Functions.LIKE.infix(self, pattern) } let like: Expression = "LIKE".infix(self, pattern, wrap: false) return Expression("(\(like.template) ESCAPE ?)", like.bindings + [String(character)]) @@ -485,7 +519,7 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression appended with a `GLOB` query against /// the given pattern. public func glob(_ pattern: String) -> Expression { - return "GLOB".infix(self, pattern) + return Functions.GLOB.infix(self, pattern) } /// Builds a copy of the expression appended with a `MATCH` query against @@ -500,7 +534,7 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression appended with a `MATCH` query /// against the given pattern. public func match(_ pattern: String) -> Expression { - return "MATCH".infix(self, pattern) + return Functions.MATCH.infix(self, pattern) } /// Builds a copy of the expression appended with a `REGEXP` query against @@ -511,7 +545,7 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression appended with a `REGEXP` query /// against the given pattern. public func regexp(_ pattern: String) -> Expression { - return "REGEXP".infix(self, pattern) + return Functions.REGEXP.infix(self, pattern) } /// Builds a copy of the expression appended with a `COLLATE` clause with @@ -526,7 +560,7 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression appended with a `COLLATE` clause /// with the given sequence. public func collate(_ collation: Collation) -> Expression { - return "COLLATE".infix(self, collation) + return Functions.COLLATE.infix(self, collation) } /// Builds a copy of the expression wrapped with the `ltrim` function. @@ -542,9 +576,9 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression wrapped with the `ltrim` function. public func ltrim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return "ltrim".wrap(self) + return Functions.ltrim.wrap(self) } - return "ltrim".wrap([self, String(characters)]) + return Functions.ltrim.wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `rtrim` function. @@ -560,9 +594,9 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression wrapped with the `rtrim` function. public func rtrim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return "rtrim".wrap(self) + return Functions.rtrim.wrap(self) } - return "rtrim".wrap([self, String(characters)]) + return Functions.rtrim.wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `trim` function. @@ -578,9 +612,9 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression wrapped with the `trim` function. public func trim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return "trim".wrap(self) + return Functions.trim.wrap(self) } - return "trim".wrap([self, String(characters)]) + return Functions.trim.wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `replace` function. @@ -597,7 +631,7 @@ extension ExpressionType where UnderlyingType == String? { /// /// - Returns: A copy of the expression wrapped with the `replace` function. public func replace(_ pattern: String, with replacement: String) -> Expression { - return "replace".wrap([self, pattern, replacement]) + return Functions.replace.wrap([self, pattern, replacement]) } /// Builds a copy of the expression wrapped with the `substr` function. @@ -617,9 +651,9 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression wrapped with the `substr` function. public func substring(_ location: Int, length: Int? = nil) -> Expression { guard let length = length else { - return "substr".wrap([self, location]) + return Functions.substr.wrap([self, location]) } - return "substr".wrap([self, location, length]) + return Functions.substr.wrap([self, location, length]) } /// Builds a copy of the expression wrapped with the `substr` function. @@ -652,7 +686,7 @@ extension Collection where Iterator.Element : Value { /// the collection. public func contains(_ expression: Expression) -> Expression { let templates = [String](repeating: "?", count: count).joined(separator: ", ") - return "IN".infix(expression, Expression("(\(templates))", map { $0.datatypeValue })) + return Functions.IN.infix(expression, Expression("(\(templates))", map { $0.datatypeValue })) } /// Builds a copy of the expression prepended with an `IN` check against the @@ -668,7 +702,7 @@ extension Collection where Iterator.Element : Value { /// the collection. public func contains(_ expression: Expression) -> Expression { let templates = [String](repeating: "?", count: count).joined(separator: ", ") - return "IN".infix(expression, Expression("(\(templates))", map { $0.datatypeValue })) + return Functions.IN.infix(expression, Expression("(\(templates))", map { $0.datatypeValue })) } } @@ -694,7 +728,7 @@ extension String { /// the given pattern. public func like(_ pattern: Expression, escape character: Character? = nil) -> Expression { guard let character = character else { - return "LIKE".infix(self, pattern) + return Functions.LIKE.infix(self, pattern) } let like: Expression = "LIKE".infix(self, pattern, wrap: false) return Expression("(\(like.template) ESCAPE ?)", like.bindings + [String(character)]) @@ -718,7 +752,7 @@ extension String { /// - Returns: A copy of the given expressions wrapped with the `ifnull` /// function. public func ??(optional: Expression, defaultValue: V) -> Expression { - return "ifnull".wrap([optional, defaultValue]) + return Functions.ifnull.wrap([optional, defaultValue]) } /// Builds a copy of the given expressions wrapped with the `ifnull` function. @@ -738,7 +772,7 @@ public func ??(optional: Expression, defaultValue: V) -> Expressi /// - Returns: A copy of the given expressions wrapped with the `ifnull` /// function. public func ??(optional: Expression, defaultValue: Expression) -> Expression { - return "ifnull".wrap([optional, defaultValue]) + return Functions.ifnull.wrap([optional, defaultValue]) } /// Builds a copy of the given expressions wrapped with the `ifnull` function. @@ -758,5 +792,5 @@ public func ??(optional: Expression, defaultValue: Expression) /// - Returns: A copy of the given expressions wrapped with the `ifnull` /// function. public func ??(optional: Expression, defaultValue: Expression) -> Expression { - return "ifnull".wrap([optional, defaultValue]) + return Functions.ifnull.wrap([optional, defaultValue]) } diff --git a/Sources/SQLite/Typed/Operators.swift b/Sources/SQLite/Typed/Operators.swift index 5f8be14b..751215e3 100644 --- a/Sources/SQLite/Typed/Operators.swift +++ b/Sources/SQLite/Typed/Operators.swift @@ -24,266 +24,297 @@ // TODO: use `@warn_unused_result` by the time operator functions support it +private enum Operators: String { + case plus = "+" + case minus = "-" + case or = "OR" + case and = "AND" + case not = "NOT " + case mul = "*" + case div = "/" + case mod = "%" + case bitwiseLeft = "<<" + case bitwiseRight = ">>" + case bitwiseAnd = "&" + case bitwiseOr = "|" + case bitwiseXor = "~" + case eq = "=" + case neq = "!=" + case gt = ">" + case lt = "<" + case gte = ">=" + case lte = "<=" + case concatenate = "||" + + func infix(_ lhs: Expressible, _ rhs: Expressible, wrap: Bool = true) -> Expression { + return self.rawValue.infix(lhs, rhs, wrap: wrap) + } + + func wrap(_ expression: Expressible) -> Expression { + return self.rawValue.wrap(expression) + } +} + public func +(lhs: Expression, rhs: Expression) -> Expression { - return "||".infix(lhs, rhs) + return Operators.concatenate.infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression { - return "||".infix(lhs, rhs) + return Operators.concatenate.infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression { - return "||".infix(lhs, rhs) + return Operators.concatenate.infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression { - return "||".infix(lhs, rhs) + return Operators.concatenate.infix(lhs, rhs) } public func +(lhs: Expression, rhs: String) -> Expression { - return "||".infix(lhs, rhs) + return Operators.concatenate.infix(lhs, rhs) } public func +(lhs: Expression, rhs: String) -> Expression { - return "||".infix(lhs, rhs) + return Operators.concatenate.infix(lhs, rhs) } public func +(lhs: String, rhs: Expression) -> Expression { - return "||".infix(lhs, rhs) + return Operators.concatenate.infix(lhs, rhs) } public func +(lhs: String, rhs: Expression) -> Expression { - return "||".infix(lhs, rhs) + return Operators.concatenate.infix(lhs, rhs) } // MARK: - public func +(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "+".infix(lhs, rhs) + return Operators.plus.infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "+".infix(lhs, rhs) + return Operators.plus.infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "+".infix(lhs, rhs) + return Operators.plus.infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "+".infix(lhs, rhs) + return Operators.plus.infix(lhs, rhs) } public func +(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return "+".infix(lhs, rhs) + return Operators.plus.infix(lhs, rhs) } public func +(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return "+".infix(lhs, rhs) + return Operators.plus.infix(lhs, rhs) } public func +(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return "+".infix(lhs, rhs) + return Operators.plus.infix(lhs, rhs) } public func +(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return "+".infix(lhs, rhs) + return Operators.plus.infix(lhs, rhs) } public func -(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "-".infix(lhs, rhs) + return Operators.minus.infix(lhs, rhs) } public func -(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "-".infix(lhs, rhs) + return Operators.minus.infix(lhs, rhs) } public func -(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "-".infix(lhs, rhs) + return Operators.minus.infix(lhs, rhs) } public func -(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "-".infix(lhs, rhs) + return Operators.minus.infix(lhs, rhs) } public func -(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return "-".infix(lhs, rhs) + return Operators.minus.infix(lhs, rhs) } public func -(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return "-".infix(lhs, rhs) + return Operators.minus.infix(lhs, rhs) } public func -(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return "-".infix(lhs, rhs) + return Operators.minus.infix(lhs, rhs) } public func -(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return "-".infix(lhs, rhs) + return Operators.minus.infix(lhs, rhs) } public func *(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "*".infix(lhs, rhs) + return Operators.mul.infix(lhs, rhs) } public func *(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "*".infix(lhs, rhs) + return Operators.mul.infix(lhs, rhs) } public func *(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "*".infix(lhs, rhs) + return Operators.mul.infix(lhs, rhs) } public func *(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "*".infix(lhs, rhs) + return Operators.mul.infix(lhs, rhs) } public func *(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return "*".infix(lhs, rhs) + return Operators.mul.infix(lhs, rhs) } public func *(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return "*".infix(lhs, rhs) + return Operators.mul.infix(lhs, rhs) } public func *(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return "*".infix(lhs, rhs) + return Operators.mul.infix(lhs, rhs) } public func *(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return "*".infix(lhs, rhs) + return Operators.mul.infix(lhs, rhs) } public func /(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "/".infix(lhs, rhs) + return Operators.div.infix(lhs, rhs) } public func /(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "/".infix(lhs, rhs) + return Operators.div.infix(lhs, rhs) } public func /(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "/".infix(lhs, rhs) + return Operators.div.infix(lhs, rhs) } public func /(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return "/".infix(lhs, rhs) + return Operators.div.infix(lhs, rhs) } public func /(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return "/".infix(lhs, rhs) + return Operators.div.infix(lhs, rhs) } public func /(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return "/".infix(lhs, rhs) + return Operators.div.infix(lhs, rhs) } public func /(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return "/".infix(lhs, rhs) + return Operators.div.infix(lhs, rhs) } public func /(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return "/".infix(lhs, rhs) + return Operators.div.infix(lhs, rhs) } public prefix func -(rhs: Expression) -> Expression where V.Datatype : Number { - return "-".wrap(rhs) + return Operators.minus.wrap(rhs) } public prefix func -(rhs: Expression) -> Expression where V.Datatype : Number { - return "-".wrap(rhs) + return Operators.minus.wrap(rhs) } // MARK: - public func %(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "%".infix(lhs, rhs) + return Operators.mod.infix(lhs, rhs) } public func %(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "%".infix(lhs, rhs) + return Operators.mod.infix(lhs, rhs) } public func %(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "%".infix(lhs, rhs) + return Operators.mod.infix(lhs, rhs) } public func %(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "%".infix(lhs, rhs) + return Operators.mod.infix(lhs, rhs) } public func %(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return "%".infix(lhs, rhs) + return Operators.mod.infix(lhs, rhs) } public func %(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return "%".infix(lhs, rhs) + return Operators.mod.infix(lhs, rhs) } public func %(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "%".infix(lhs, rhs) + return Operators.mod.infix(lhs, rhs) } public func %(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "%".infix(lhs, rhs) + return Operators.mod.infix(lhs, rhs) } public func <<(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "<<".infix(lhs, rhs) + return Operators.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "<<".infix(lhs, rhs) + return Operators.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "<<".infix(lhs, rhs) + return Operators.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "<<".infix(lhs, rhs) + return Operators.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return "<<".infix(lhs, rhs) + return Operators.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return "<<".infix(lhs, rhs) + return Operators.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "<<".infix(lhs, rhs) + return Operators.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "<<".infix(lhs, rhs) + return Operators.bitwiseLeft.infix(lhs, rhs) } public func >>(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return ">>".infix(lhs, rhs) + return Operators.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return ">>".infix(lhs, rhs) + return Operators.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return ">>".infix(lhs, rhs) + return Operators.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return ">>".infix(lhs, rhs) + return Operators.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return ">>".infix(lhs, rhs) + return Operators.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return ">>".infix(lhs, rhs) + return Operators.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return ">>".infix(lhs, rhs) + return Operators.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return ">>".infix(lhs, rhs) + return Operators.bitwiseRight.infix(lhs, rhs) } public func &(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "&".infix(lhs, rhs) + return Operators.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "&".infix(lhs, rhs) + return Operators.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "&".infix(lhs, rhs) + return Operators.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "&".infix(lhs, rhs) + return Operators.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return "&".infix(lhs, rhs) + return Operators.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return "&".infix(lhs, rhs) + return Operators.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "&".infix(lhs, rhs) + return Operators.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "&".infix(lhs, rhs) + return Operators.bitwiseAnd.infix(lhs, rhs) } public func |(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "|".infix(lhs, rhs) + return Operators.bitwiseOr.infix(lhs, rhs) } public func |(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "|".infix(lhs, rhs) + return Operators.bitwiseOr.infix(lhs, rhs) } public func |(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "|".infix(lhs, rhs) + return Operators.bitwiseOr.infix(lhs, rhs) } public func |(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "|".infix(lhs, rhs) + return Operators.bitwiseOr.infix(lhs, rhs) } public func |(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return "|".infix(lhs, rhs) + return Operators.bitwiseOr.infix(lhs, rhs) } public func |(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return "|".infix(lhs, rhs) + return Operators.bitwiseOr.infix(lhs, rhs) } public func |(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "|".infix(lhs, rhs) + return Operators.bitwiseOr.infix(lhs, rhs) } public func |(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return "|".infix(lhs, rhs) + return Operators.bitwiseOr.infix(lhs, rhs) } public func ^(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { @@ -312,166 +343,166 @@ public func ^(lhs: V, rhs: Expression) -> Expression where V. } public prefix func ~(rhs: Expression) -> Expression where V.Datatype == Int64 { - return "~".wrap(rhs) + return Operators.bitwiseXor.wrap(rhs) } public prefix func ~(rhs: Expression) -> Expression where V.Datatype == Int64 { - return "~".wrap(rhs) + return Operators.bitwiseXor.wrap(rhs) } // MARK: - public func ==(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return "=".infix(lhs, rhs) + return Operators.eq.infix(lhs, rhs) } public func ==(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return "=".infix(lhs, rhs) + return Operators.eq.infix(lhs, rhs) } public func ==(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return "=".infix(lhs, rhs) + return Operators.eq.infix(lhs, rhs) } public func ==(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return "=".infix(lhs, rhs) + return Operators.eq.infix(lhs, rhs) } public func ==(lhs: Expression, rhs: V) -> Expression where V.Datatype : Equatable { - return "=".infix(lhs, rhs) + return Operators.eq.infix(lhs, rhs) } public func ==(lhs: Expression, rhs: V?) -> Expression where V.Datatype : Equatable { guard let rhs = rhs else { return "IS".infix(lhs, Expression(value: nil)) } - return "=".infix(lhs, rhs) + return Operators.eq.infix(lhs, rhs) } public func ==(lhs: V, rhs: Expression) -> Expression where V.Datatype : Equatable { - return "=".infix(lhs, rhs) + return Operators.eq.infix(lhs, rhs) } public func ==(lhs: V?, rhs: Expression) -> Expression where V.Datatype : Equatable { guard let lhs = lhs else { return "IS".infix(Expression(value: nil), rhs) } - return "=".infix(lhs, rhs) + return Operators.eq.infix(lhs, rhs) } public func !=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return "!=".infix(lhs, rhs) + return Operators.neq.infix(lhs, rhs) } public func !=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return "!=".infix(lhs, rhs) + return Operators.neq.infix(lhs, rhs) } public func !=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return "!=".infix(lhs, rhs) + return Operators.neq.infix(lhs, rhs) } public func !=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return "!=".infix(lhs, rhs) + return Operators.neq.infix(lhs, rhs) } public func !=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Equatable { - return "!=".infix(lhs, rhs) + return Operators.neq.infix(lhs, rhs) } public func !=(lhs: Expression, rhs: V?) -> Expression where V.Datatype : Equatable { guard let rhs = rhs else { return "IS NOT".infix(lhs, Expression(value: nil)) } - return "!=".infix(lhs, rhs) + return Operators.neq.infix(lhs, rhs) } public func !=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Equatable { - return "!=".infix(lhs, rhs) + return Operators.neq.infix(lhs, rhs) } public func !=(lhs: V?, rhs: Expression) -> Expression where V.Datatype : Equatable { guard let lhs = lhs else { return "IS NOT".infix(Expression(value: nil), rhs) } - return "!=".infix(lhs, rhs) + return Operators.neq.infix(lhs, rhs) } public func >(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return ">".infix(lhs, rhs) + return Operators.gt.infix(lhs, rhs) } public func >(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return ">".infix(lhs, rhs) + return Operators.gt.infix(lhs, rhs) } public func >(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return ">".infix(lhs, rhs) + return Operators.gt.infix(lhs, rhs) } public func >(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return ">".infix(lhs, rhs) + return Operators.gt.infix(lhs, rhs) } public func >(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return ">".infix(lhs, rhs) + return Operators.gt.infix(lhs, rhs) } public func >(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return ">".infix(lhs, rhs) + return Operators.gt.infix(lhs, rhs) } public func >(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return ">".infix(lhs, rhs) + return Operators.gt.infix(lhs, rhs) } public func >(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return ">".infix(lhs, rhs) + return Operators.gt.infix(lhs, rhs) } public func >=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return ">=".infix(lhs, rhs) + return Operators.gte.infix(lhs, rhs) } public func >=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return ">=".infix(lhs, rhs) + return Operators.gte.infix(lhs, rhs) } public func >=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return ">=".infix(lhs, rhs) + return Operators.gte.infix(lhs, rhs) } public func >=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return ">=".infix(lhs, rhs) + return Operators.gte.infix(lhs, rhs) } public func >=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return ">=".infix(lhs, rhs) + return Operators.gte.infix(lhs, rhs) } public func >=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return ">=".infix(lhs, rhs) + return Operators.gte.infix(lhs, rhs) } public func >=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return ">=".infix(lhs, rhs) + return Operators.gte.infix(lhs, rhs) } public func >=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return ">=".infix(lhs, rhs) + return Operators.gte.infix(lhs, rhs) } public func <(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return "<".infix(lhs, rhs) + return Operators.lt.infix(lhs, rhs) } public func <(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return "<".infix(lhs, rhs) + return Operators.lt.infix(lhs, rhs) } public func <(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return "<".infix(lhs, rhs) + return Operators.lt.infix(lhs, rhs) } public func <(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return "<".infix(lhs, rhs) + return Operators.lt.infix(lhs, rhs) } public func <(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return "<".infix(lhs, rhs) + return Operators.lt.infix(lhs, rhs) } public func <(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return "<".infix(lhs, rhs) + return Operators.lt.infix(lhs, rhs) } public func <(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return "<".infix(lhs, rhs) + return Operators.lt.infix(lhs, rhs) } public func <(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return "<".infix(lhs, rhs) + return Operators.lt.infix(lhs, rhs) } public func <=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return "<=".infix(lhs, rhs) + return Operators.lte.infix(lhs, rhs) } public func <=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return "<=".infix(lhs, rhs) + return Operators.lte.infix(lhs, rhs) } public func <=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return "<=".infix(lhs, rhs) + return Operators.lte.infix(lhs, rhs) } public func <=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return "<=".infix(lhs, rhs) + return Operators.lte.infix(lhs, rhs) } public func <=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return "<=".infix(lhs, rhs) + return Operators.lte.infix(lhs, rhs) } public func <=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return "<=".infix(lhs, rhs) + return Operators.lte.infix(lhs, rhs) } public func <=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return "<=".infix(lhs, rhs) + return Operators.lte.infix(lhs, rhs) } public func <=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return "<=".infix(lhs, rhs) + return Operators.lte.infix(lhs, rhs) } public func ~=(lhs: ClosedRange, rhs: Expression) -> Expression where V.Datatype : Comparable & Value { @@ -517,58 +548,58 @@ public func ~=(lhs: PartialRangeFrom, rhs: Expression) -> Expr // MARK: - public func &&(lhs: Expression, rhs: Expression) -> Expression { - return "AND".infix(lhs, rhs) + return Operators.and.infix(lhs, rhs) } public func &&(lhs: Expression, rhs: Expression) -> Expression { - return "AND".infix(lhs, rhs) + return Operators.and.infix(lhs, rhs) } public func &&(lhs: Expression, rhs: Expression) -> Expression { - return "AND".infix(lhs, rhs) + return Operators.and.infix(lhs, rhs) } public func &&(lhs: Expression, rhs: Expression) -> Expression { - return "AND".infix(lhs, rhs) + return Operators.and.infix(lhs, rhs) } public func &&(lhs: Expression, rhs: Bool) -> Expression { - return "AND".infix(lhs, rhs) + return Operators.and.infix(lhs, rhs) } public func &&(lhs: Expression, rhs: Bool) -> Expression { - return "AND".infix(lhs, rhs) + return Operators.and.infix(lhs, rhs) } public func &&(lhs: Bool, rhs: Expression) -> Expression { - return "AND".infix(lhs, rhs) + return Operators.and.infix(lhs, rhs) } public func &&(lhs: Bool, rhs: Expression) -> Expression { - return "AND".infix(lhs, rhs) + return Operators.and.infix(lhs, rhs) } public func ||(lhs: Expression, rhs: Expression) -> Expression { - return "OR".infix(lhs, rhs) + return Operators.or.infix(lhs, rhs) } public func ||(lhs: Expression, rhs: Expression) -> Expression { - return "OR".infix(lhs, rhs) + return Operators.or.infix(lhs, rhs) } public func ||(lhs: Expression, rhs: Expression) -> Expression { - return "OR".infix(lhs, rhs) + return Operators.or.infix(lhs, rhs) } public func ||(lhs: Expression, rhs: Expression) -> Expression { - return "OR".infix(lhs, rhs) + return Operators.or.infix(lhs, rhs) } public func ||(lhs: Expression, rhs: Bool) -> Expression { - return "OR".infix(lhs, rhs) + return Operators.or.infix(lhs, rhs) } public func ||(lhs: Expression, rhs: Bool) -> Expression { - return "OR".infix(lhs, rhs) + return Operators.or.infix(lhs, rhs) } public func ||(lhs: Bool, rhs: Expression) -> Expression { - return "OR".infix(lhs, rhs) + return Operators.or.infix(lhs, rhs) } public func ||(lhs: Bool, rhs: Expression) -> Expression { - return "OR".infix(lhs, rhs) + return Operators.or.infix(lhs, rhs) } public prefix func !(rhs: Expression) -> Expression { - return "NOT ".wrap(rhs) + return Operators.not.wrap(rhs) } public prefix func !(rhs: Expression) -> Expression { - return "NOT ".wrap(rhs) + return Operators.not.wrap(rhs) } From bc909add007da81916c8b9118df081d746aea4c4 Mon Sep 17 00:00:00 2001 From: Yehor Popovych Date: Wed, 27 Mar 2019 13:48:58 +0200 Subject: [PATCH 3/3] Fixed enums naming --- Sources/SQLite/Typed/AggregateFunctions.swift | 28 +- Sources/SQLite/Typed/CoreFunctions.swift | 124 +++---- Sources/SQLite/Typed/Operators.swift | 302 +++++++++--------- 3 files changed, 227 insertions(+), 227 deletions(-) diff --git a/Sources/SQLite/Typed/AggregateFunctions.swift b/Sources/SQLite/Typed/AggregateFunctions.swift index 056d617e..2ec28288 100644 --- a/Sources/SQLite/Typed/AggregateFunctions.swift +++ b/Sources/SQLite/Typed/AggregateFunctions.swift @@ -22,7 +22,7 @@ // THE SOFTWARE. // -private enum Functions: String { +private enum Function: String { case count case max case min @@ -61,7 +61,7 @@ extension ExpressionType where UnderlyingType : Value { /// - Returns: A copy of the expression wrapped with the `count` aggregate /// function. public var count: Expression { - return Functions.count.wrap(self) + return Function.count.wrap(self) } } @@ -92,7 +92,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `count` aggregate /// function. public var count: Expression { - return Functions.count.wrap(self) + return Function.count.wrap(self) } } @@ -109,7 +109,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `max` aggregate /// function. public var max: Expression { - return Functions.max.wrap(self) + return Function.max.wrap(self) } /// Builds a copy of the expression wrapped with the `min` aggregate @@ -122,7 +122,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var min: Expression { - return Functions.min.wrap(self) + return Function.min.wrap(self) } } @@ -139,7 +139,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `max` aggregate /// function. public var max: Expression { - return Functions.max.wrap(self) + return Function.max.wrap(self) } /// Builds a copy of the expression wrapped with the `min` aggregate @@ -152,7 +152,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var min: Expression { - return Functions.min.wrap(self) + return Function.min.wrap(self) } } @@ -169,7 +169,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var average: Expression { - return Functions.avg.wrap(self) + return Function.avg.wrap(self) } /// Builds a copy of the expression wrapped with the `sum` aggregate @@ -182,7 +182,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var sum: Expression { - return Functions.sum.wrap(self) + return Function.sum.wrap(self) } /// Builds a copy of the expression wrapped with the `total` aggregate @@ -195,7 +195,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var total: Expression { - return Functions.total.wrap(self) + return Function.total.wrap(self) } } @@ -212,7 +212,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var average: Expression { - return Functions.avg.wrap(self) + return Function.avg.wrap(self) } /// Builds a copy of the expression wrapped with the `sum` aggregate @@ -225,7 +225,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var sum: Expression { - return Functions.sum.wrap(self) + return Function.sum.wrap(self) } /// Builds a copy of the expression wrapped with the `total` aggregate @@ -238,7 +238,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// - Returns: A copy of the expression wrapped with the `min` aggregate /// function. public var total: Expression { - return Functions.total.wrap(self) + return Function.total.wrap(self) } } @@ -246,7 +246,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr extension ExpressionType where UnderlyingType == Int { static func count(_ star: Star) -> Expression { - return Functions.count.wrap(star(nil, nil)) + return Function.count.wrap(star(nil, nil)) } } diff --git a/Sources/SQLite/Typed/CoreFunctions.swift b/Sources/SQLite/Typed/CoreFunctions.swift index 420110ae..068dcf02 100644 --- a/Sources/SQLite/Typed/CoreFunctions.swift +++ b/Sources/SQLite/Typed/CoreFunctions.swift @@ -24,7 +24,7 @@ import Foundation -private enum Functions: String { +private enum Function: String { case abs case round case random @@ -38,12 +38,12 @@ private enum Functions: String { case trim case replace case substr - case LIKE - case IN - case GLOB - case MATCH - case REGEXP - case COLLATE + case like = "LIKE" + case `in` = "IN" + case glob = "GLOB" + case match = "MATCH" + case regexp = "REGEXP" + case collate = "COLLATE" case ifnull func infix(_ lhs: Expressible, _ rhs: Expressible, wrap: Bool = true) -> Expression { @@ -69,7 +69,7 @@ extension ExpressionType where UnderlyingType : Number { /// /// - Returns: A copy of the expression wrapped with the `abs` function. public var absoluteValue : Expression { - return Functions.abs.wrap(self) + return Function.abs.wrap(self) } } @@ -84,7 +84,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr /// /// - Returns: A copy of the expression wrapped with the `abs` function. public var absoluteValue : Expression { - return Functions.abs.wrap(self) + return Function.abs.wrap(self) } } @@ -102,9 +102,9 @@ extension ExpressionType where UnderlyingType == Double { /// - Returns: A copy of the expression wrapped with the `round` function. public func round(_ precision: Int? = nil) -> Expression { guard let precision = precision else { - return Functions.round.wrap([self]) + return Function.round.wrap([self]) } - return Functions.round.wrap([self, Int(precision)]) + return Function.round.wrap([self, Int(precision)]) } } @@ -122,9 +122,9 @@ extension ExpressionType where UnderlyingType == Double? { /// - Returns: A copy of the expression wrapped with the `round` function. public func round(_ precision: Int? = nil) -> Expression { guard let precision = precision else { - return Functions.round.wrap(self) + return Function.round.wrap(self) } - return Functions.round.wrap([self, Int(precision)]) + return Function.round.wrap([self, Int(precision)]) } } @@ -138,7 +138,7 @@ extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype = /// /// - Returns: An expression calling the `random` function. public static func random() -> Expression { - return Functions.random.wrap([]) + return Function.random.wrap([]) } } @@ -154,7 +154,7 @@ extension ExpressionType where UnderlyingType == Data { /// /// - Returns: An expression calling the `randomblob` function. public static func random(_ length: Int) -> Expression { - return Functions.randomblob.wrap([]) + return Function.randomblob.wrap([]) } /// Builds an expression representing the `zeroblob` function. @@ -166,7 +166,7 @@ extension ExpressionType where UnderlyingType == Data { /// /// - Returns: An expression calling the `zeroblob` function. public static func allZeros(_ length: Int) -> Expression { - return Functions.zeroblob.wrap([]) + return Function.zeroblob.wrap([]) } /// Builds a copy of the expression wrapped with the `length` function. @@ -177,7 +177,7 @@ extension ExpressionType where UnderlyingType == Data { /// /// - Returns: A copy of the expression wrapped with the `length` function. public var length: Expression { - return Functions.length.wrap(self) + return Function.length.wrap(self) } } @@ -192,7 +192,7 @@ extension ExpressionType where UnderlyingType == Data? { /// /// - Returns: A copy of the expression wrapped with the `length` function. public var length: Expression { - return Functions.length.wrap(self) + return Function.length.wrap(self) } } @@ -207,7 +207,7 @@ extension ExpressionType where UnderlyingType == String { /// /// - Returns: A copy of the expression wrapped with the `length` function. public var length: Expression { - return Functions.length.wrap(self) + return Function.length.wrap(self) } /// Builds a copy of the expression wrapped with the `lower` function. @@ -218,7 +218,7 @@ extension ExpressionType where UnderlyingType == String { /// /// - Returns: A copy of the expression wrapped with the `lower` function. public var lowercaseString: Expression { - return Functions.lower.wrap(self) + return Function.lower.wrap(self) } /// Builds a copy of the expression wrapped with the `upper` function. @@ -229,7 +229,7 @@ extension ExpressionType where UnderlyingType == String { /// /// - Returns: A copy of the expression wrapped with the `upper` function. public var uppercaseString: Expression { - return Functions.upper.wrap(self) + return Function.upper.wrap(self) } /// Builds a copy of the expression appended with a `LIKE` query against the @@ -276,9 +276,9 @@ extension ExpressionType where UnderlyingType == String { /// the given pattern. public func like(_ pattern: Expression, escape character: Character? = nil) -> Expression { guard let character = character else { - return Functions.LIKE.infix(self, pattern) + return Function.like.infix(self, pattern) } - let like: Expression = Functions.LIKE.infix(self, pattern, wrap: false) + let like: Expression = Function.like.infix(self, pattern, wrap: false) return Expression("(\(like.template) ESCAPE ?)", like.bindings + [String(character)]) } @@ -294,7 +294,7 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression appended with a `GLOB` query against /// the given pattern. public func glob(_ pattern: String) -> Expression { - return Functions.GLOB.infix(self, pattern) + return Function.glob.infix(self, pattern) } /// Builds a copy of the expression appended with a `MATCH` query against @@ -309,7 +309,7 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression appended with a `MATCH` query /// against the given pattern. public func match(_ pattern: String) -> Expression { - return Functions.MATCH.infix(self, pattern) + return Function.match.infix(self, pattern) } /// Builds a copy of the expression appended with a `REGEXP` query against @@ -320,7 +320,7 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression appended with a `REGEXP` query /// against the given pattern. public func regexp(_ pattern: String) -> Expression { - return Functions.REGEXP.infix(self, pattern) + return Function.regexp.infix(self, pattern) } /// Builds a copy of the expression appended with a `COLLATE` clause with @@ -335,7 +335,7 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression appended with a `COLLATE` clause /// with the given sequence. public func collate(_ collation: Collation) -> Expression { - return Functions.COLLATE.infix(self, collation) + return Function.collate.infix(self, collation) } /// Builds a copy of the expression wrapped with the `ltrim` function. @@ -351,9 +351,9 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression wrapped with the `ltrim` function. public func ltrim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return Functions.ltrim.wrap(self) + return Function.ltrim.wrap(self) } - return Functions.ltrim.wrap([self, String(characters)]) + return Function.ltrim.wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `rtrim` function. @@ -369,9 +369,9 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression wrapped with the `rtrim` function. public func rtrim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return Functions.rtrim.wrap(self) + return Function.rtrim.wrap(self) } - return Functions.rtrim.wrap([self, String(characters)]) + return Function.rtrim.wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `trim` function. @@ -387,9 +387,9 @@ extension ExpressionType where UnderlyingType == String { /// - Returns: A copy of the expression wrapped with the `trim` function. public func trim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return Functions.trim.wrap([self]) + return Function.trim.wrap([self]) } - return Functions.trim.wrap([self, String(characters)]) + return Function.trim.wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `replace` function. @@ -406,14 +406,14 @@ extension ExpressionType where UnderlyingType == String { /// /// - Returns: A copy of the expression wrapped with the `replace` function. public func replace(_ pattern: String, with replacement: String) -> Expression { - return Functions.replace.wrap([self, pattern, replacement]) + return Function.replace.wrap([self, pattern, replacement]) } public func substring(_ location: Int, length: Int? = nil) -> Expression { guard let length = length else { - return Functions.substr.wrap([self, location]) + return Function.substr.wrap([self, location]) } - return Functions.substr.wrap([self, location, length]) + return Function.substr.wrap([self, location, length]) } public subscript(range: Range) -> Expression { @@ -432,7 +432,7 @@ extension ExpressionType where UnderlyingType == String? { /// /// - Returns: A copy of the expression wrapped with the `length` function. public var length: Expression { - return Functions.length.wrap(self) + return Function.length.wrap(self) } /// Builds a copy of the expression wrapped with the `lower` function. @@ -443,7 +443,7 @@ extension ExpressionType where UnderlyingType == String? { /// /// - Returns: A copy of the expression wrapped with the `lower` function. public var lowercaseString: Expression { - return Functions.lower.wrap(self) + return Function.lower.wrap(self) } /// Builds a copy of the expression wrapped with the `upper` function. @@ -454,7 +454,7 @@ extension ExpressionType where UnderlyingType == String? { /// /// - Returns: A copy of the expression wrapped with the `upper` function. public var uppercaseString: Expression { - return Functions.upper.wrap(self) + return Function.upper.wrap(self) } /// Builds a copy of the expression appended with a `LIKE` query against the @@ -477,7 +477,7 @@ extension ExpressionType where UnderlyingType == String? { /// the given pattern. public func like(_ pattern: String, escape character: Character? = nil) -> Expression { guard let character = character else { - return Functions.LIKE.infix(self, pattern) + return Function.like.infix(self, pattern) } return Expression("(\(template) LIKE ? ESCAPE ?)", bindings + [pattern, String(character)]) } @@ -501,9 +501,9 @@ extension ExpressionType where UnderlyingType == String? { /// the given pattern. public func like(_ pattern: Expression, escape character: Character? = nil) -> Expression { guard let character = character else { - return Functions.LIKE.infix(self, pattern) + return Function.like.infix(self, pattern) } - let like: Expression = "LIKE".infix(self, pattern, wrap: false) + let like: Expression = Function.like.infix(self, pattern, wrap: false) return Expression("(\(like.template) ESCAPE ?)", like.bindings + [String(character)]) } @@ -519,7 +519,7 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression appended with a `GLOB` query against /// the given pattern. public func glob(_ pattern: String) -> Expression { - return Functions.GLOB.infix(self, pattern) + return Function.glob.infix(self, pattern) } /// Builds a copy of the expression appended with a `MATCH` query against @@ -534,7 +534,7 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression appended with a `MATCH` query /// against the given pattern. public func match(_ pattern: String) -> Expression { - return Functions.MATCH.infix(self, pattern) + return Function.match.infix(self, pattern) } /// Builds a copy of the expression appended with a `REGEXP` query against @@ -545,7 +545,7 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression appended with a `REGEXP` query /// against the given pattern. public func regexp(_ pattern: String) -> Expression { - return Functions.REGEXP.infix(self, pattern) + return Function.regexp.infix(self, pattern) } /// Builds a copy of the expression appended with a `COLLATE` clause with @@ -560,7 +560,7 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression appended with a `COLLATE` clause /// with the given sequence. public func collate(_ collation: Collation) -> Expression { - return Functions.COLLATE.infix(self, collation) + return Function.collate.infix(self, collation) } /// Builds a copy of the expression wrapped with the `ltrim` function. @@ -576,9 +576,9 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression wrapped with the `ltrim` function. public func ltrim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return Functions.ltrim.wrap(self) + return Function.ltrim.wrap(self) } - return Functions.ltrim.wrap([self, String(characters)]) + return Function.ltrim.wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `rtrim` function. @@ -594,9 +594,9 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression wrapped with the `rtrim` function. public func rtrim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return Functions.rtrim.wrap(self) + return Function.rtrim.wrap(self) } - return Functions.rtrim.wrap([self, String(characters)]) + return Function.rtrim.wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `trim` function. @@ -612,9 +612,9 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression wrapped with the `trim` function. public func trim(_ characters: Set? = nil) -> Expression { guard let characters = characters else { - return Functions.trim.wrap(self) + return Function.trim.wrap(self) } - return Functions.trim.wrap([self, String(characters)]) + return Function.trim.wrap([self, String(characters)]) } /// Builds a copy of the expression wrapped with the `replace` function. @@ -631,7 +631,7 @@ extension ExpressionType where UnderlyingType == String? { /// /// - Returns: A copy of the expression wrapped with the `replace` function. public func replace(_ pattern: String, with replacement: String) -> Expression { - return Functions.replace.wrap([self, pattern, replacement]) + return Function.replace.wrap([self, pattern, replacement]) } /// Builds a copy of the expression wrapped with the `substr` function. @@ -651,9 +651,9 @@ extension ExpressionType where UnderlyingType == String? { /// - Returns: A copy of the expression wrapped with the `substr` function. public func substring(_ location: Int, length: Int? = nil) -> Expression { guard let length = length else { - return Functions.substr.wrap([self, location]) + return Function.substr.wrap([self, location]) } - return Functions.substr.wrap([self, location, length]) + return Function.substr.wrap([self, location, length]) } /// Builds a copy of the expression wrapped with the `substr` function. @@ -686,7 +686,7 @@ extension Collection where Iterator.Element : Value { /// the collection. public func contains(_ expression: Expression) -> Expression { let templates = [String](repeating: "?", count: count).joined(separator: ", ") - return Functions.IN.infix(expression, Expression("(\(templates))", map { $0.datatypeValue })) + return Function.in.infix(expression, Expression("(\(templates))", map { $0.datatypeValue })) } /// Builds a copy of the expression prepended with an `IN` check against the @@ -702,7 +702,7 @@ extension Collection where Iterator.Element : Value { /// the collection. public func contains(_ expression: Expression) -> Expression { let templates = [String](repeating: "?", count: count).joined(separator: ", ") - return Functions.IN.infix(expression, Expression("(\(templates))", map { $0.datatypeValue })) + return Function.in.infix(expression, Expression("(\(templates))", map { $0.datatypeValue })) } } @@ -728,9 +728,9 @@ extension String { /// the given pattern. public func like(_ pattern: Expression, escape character: Character? = nil) -> Expression { guard let character = character else { - return Functions.LIKE.infix(self, pattern) + return Function.like.infix(self, pattern) } - let like: Expression = "LIKE".infix(self, pattern, wrap: false) + let like: Expression = Function.like.infix(self, pattern, wrap: false) return Expression("(\(like.template) ESCAPE ?)", like.bindings + [String(character)]) } @@ -752,7 +752,7 @@ extension String { /// - Returns: A copy of the given expressions wrapped with the `ifnull` /// function. public func ??(optional: Expression, defaultValue: V) -> Expression { - return Functions.ifnull.wrap([optional, defaultValue]) + return Function.ifnull.wrap([optional, defaultValue]) } /// Builds a copy of the given expressions wrapped with the `ifnull` function. @@ -772,7 +772,7 @@ public func ??(optional: Expression, defaultValue: V) -> Expressi /// - Returns: A copy of the given expressions wrapped with the `ifnull` /// function. public func ??(optional: Expression, defaultValue: Expression) -> Expression { - return Functions.ifnull.wrap([optional, defaultValue]) + return Function.ifnull.wrap([optional, defaultValue]) } /// Builds a copy of the given expressions wrapped with the `ifnull` function. @@ -792,5 +792,5 @@ public func ??(optional: Expression, defaultValue: Expression) /// - Returns: A copy of the given expressions wrapped with the `ifnull` /// function. public func ??(optional: Expression, defaultValue: Expression) -> Expression { - return Functions.ifnull.wrap([optional, defaultValue]) + return Function.ifnull.wrap([optional, defaultValue]) } diff --git a/Sources/SQLite/Typed/Operators.swift b/Sources/SQLite/Typed/Operators.swift index 751215e3..b5637ea3 100644 --- a/Sources/SQLite/Typed/Operators.swift +++ b/Sources/SQLite/Typed/Operators.swift @@ -24,7 +24,7 @@ // TODO: use `@warn_unused_result` by the time operator functions support it -private enum Operators: String { +private enum Operator: String { case plus = "+" case minus = "-" case or = "OR" @@ -56,265 +56,265 @@ private enum Operators: String { } public func +(lhs: Expression, rhs: Expression) -> Expression { - return Operators.concatenate.infix(lhs, rhs) + return Operator.concatenate.infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression { - return Operators.concatenate.infix(lhs, rhs) + return Operator.concatenate.infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression { - return Operators.concatenate.infix(lhs, rhs) + return Operator.concatenate.infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression { - return Operators.concatenate.infix(lhs, rhs) + return Operator.concatenate.infix(lhs, rhs) } public func +(lhs: Expression, rhs: String) -> Expression { - return Operators.concatenate.infix(lhs, rhs) + return Operator.concatenate.infix(lhs, rhs) } public func +(lhs: Expression, rhs: String) -> Expression { - return Operators.concatenate.infix(lhs, rhs) + return Operator.concatenate.infix(lhs, rhs) } public func +(lhs: String, rhs: Expression) -> Expression { - return Operators.concatenate.infix(lhs, rhs) + return Operator.concatenate.infix(lhs, rhs) } public func +(lhs: String, rhs: Expression) -> Expression { - return Operators.concatenate.infix(lhs, rhs) + return Operator.concatenate.infix(lhs, rhs) } // MARK: - public func +(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.plus.infix(lhs, rhs) + return Operator.plus.infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.plus.infix(lhs, rhs) + return Operator.plus.infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.plus.infix(lhs, rhs) + return Operator.plus.infix(lhs, rhs) } public func +(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.plus.infix(lhs, rhs) + return Operator.plus.infix(lhs, rhs) } public func +(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return Operators.plus.infix(lhs, rhs) + return Operator.plus.infix(lhs, rhs) } public func +(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return Operators.plus.infix(lhs, rhs) + return Operator.plus.infix(lhs, rhs) } public func +(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.plus.infix(lhs, rhs) + return Operator.plus.infix(lhs, rhs) } public func +(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.plus.infix(lhs, rhs) + return Operator.plus.infix(lhs, rhs) } public func -(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.minus.infix(lhs, rhs) + return Operator.minus.infix(lhs, rhs) } public func -(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.minus.infix(lhs, rhs) + return Operator.minus.infix(lhs, rhs) } public func -(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.minus.infix(lhs, rhs) + return Operator.minus.infix(lhs, rhs) } public func -(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.minus.infix(lhs, rhs) + return Operator.minus.infix(lhs, rhs) } public func -(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return Operators.minus.infix(lhs, rhs) + return Operator.minus.infix(lhs, rhs) } public func -(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return Operators.minus.infix(lhs, rhs) + return Operator.minus.infix(lhs, rhs) } public func -(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.minus.infix(lhs, rhs) + return Operator.minus.infix(lhs, rhs) } public func -(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.minus.infix(lhs, rhs) + return Operator.minus.infix(lhs, rhs) } public func *(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.mul.infix(lhs, rhs) + return Operator.mul.infix(lhs, rhs) } public func *(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.mul.infix(lhs, rhs) + return Operator.mul.infix(lhs, rhs) } public func *(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.mul.infix(lhs, rhs) + return Operator.mul.infix(lhs, rhs) } public func *(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.mul.infix(lhs, rhs) + return Operator.mul.infix(lhs, rhs) } public func *(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return Operators.mul.infix(lhs, rhs) + return Operator.mul.infix(lhs, rhs) } public func *(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return Operators.mul.infix(lhs, rhs) + return Operator.mul.infix(lhs, rhs) } public func *(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.mul.infix(lhs, rhs) + return Operator.mul.infix(lhs, rhs) } public func *(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.mul.infix(lhs, rhs) + return Operator.mul.infix(lhs, rhs) } public func /(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.div.infix(lhs, rhs) + return Operator.div.infix(lhs, rhs) } public func /(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.div.infix(lhs, rhs) + return Operator.div.infix(lhs, rhs) } public func /(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.div.infix(lhs, rhs) + return Operator.div.infix(lhs, rhs) } public func /(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.div.infix(lhs, rhs) + return Operator.div.infix(lhs, rhs) } public func /(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return Operators.div.infix(lhs, rhs) + return Operator.div.infix(lhs, rhs) } public func /(lhs: Expression, rhs: V) -> Expression where V.Datatype : Number { - return Operators.div.infix(lhs, rhs) + return Operator.div.infix(lhs, rhs) } public func /(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.div.infix(lhs, rhs) + return Operator.div.infix(lhs, rhs) } public func /(lhs: V, rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.div.infix(lhs, rhs) + return Operator.div.infix(lhs, rhs) } public prefix func -(rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.minus.wrap(rhs) + return Operator.minus.wrap(rhs) } public prefix func -(rhs: Expression) -> Expression where V.Datatype : Number { - return Operators.minus.wrap(rhs) + return Operator.minus.wrap(rhs) } // MARK: - public func %(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.mod.infix(lhs, rhs) + return Operator.mod.infix(lhs, rhs) } public func %(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.mod.infix(lhs, rhs) + return Operator.mod.infix(lhs, rhs) } public func %(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.mod.infix(lhs, rhs) + return Operator.mod.infix(lhs, rhs) } public func %(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.mod.infix(lhs, rhs) + return Operator.mod.infix(lhs, rhs) } public func %(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return Operators.mod.infix(lhs, rhs) + return Operator.mod.infix(lhs, rhs) } public func %(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return Operators.mod.infix(lhs, rhs) + return Operator.mod.infix(lhs, rhs) } public func %(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.mod.infix(lhs, rhs) + return Operator.mod.infix(lhs, rhs) } public func %(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.mod.infix(lhs, rhs) + return Operator.mod.infix(lhs, rhs) } public func <<(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseLeft.infix(lhs, rhs) + return Operator.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseLeft.infix(lhs, rhs) + return Operator.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseLeft.infix(lhs, rhs) + return Operator.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseLeft.infix(lhs, rhs) + return Operator.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseLeft.infix(lhs, rhs) + return Operator.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseLeft.infix(lhs, rhs) + return Operator.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseLeft.infix(lhs, rhs) + return Operator.bitwiseLeft.infix(lhs, rhs) } public func <<(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseLeft.infix(lhs, rhs) + return Operator.bitwiseLeft.infix(lhs, rhs) } public func >>(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseRight.infix(lhs, rhs) + return Operator.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseRight.infix(lhs, rhs) + return Operator.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseRight.infix(lhs, rhs) + return Operator.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseRight.infix(lhs, rhs) + return Operator.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseRight.infix(lhs, rhs) + return Operator.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseRight.infix(lhs, rhs) + return Operator.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseRight.infix(lhs, rhs) + return Operator.bitwiseRight.infix(lhs, rhs) } public func >>(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseRight.infix(lhs, rhs) + return Operator.bitwiseRight.infix(lhs, rhs) } public func &(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseAnd.infix(lhs, rhs) + return Operator.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseAnd.infix(lhs, rhs) + return Operator.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseAnd.infix(lhs, rhs) + return Operator.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseAnd.infix(lhs, rhs) + return Operator.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseAnd.infix(lhs, rhs) + return Operator.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseAnd.infix(lhs, rhs) + return Operator.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseAnd.infix(lhs, rhs) + return Operator.bitwiseAnd.infix(lhs, rhs) } public func &(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseAnd.infix(lhs, rhs) + return Operator.bitwiseAnd.infix(lhs, rhs) } public func |(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseOr.infix(lhs, rhs) + return Operator.bitwiseOr.infix(lhs, rhs) } public func |(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseOr.infix(lhs, rhs) + return Operator.bitwiseOr.infix(lhs, rhs) } public func |(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseOr.infix(lhs, rhs) + return Operator.bitwiseOr.infix(lhs, rhs) } public func |(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseOr.infix(lhs, rhs) + return Operator.bitwiseOr.infix(lhs, rhs) } public func |(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseOr.infix(lhs, rhs) + return Operator.bitwiseOr.infix(lhs, rhs) } public func |(lhs: Expression, rhs: V) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseOr.infix(lhs, rhs) + return Operator.bitwiseOr.infix(lhs, rhs) } public func |(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseOr.infix(lhs, rhs) + return Operator.bitwiseOr.infix(lhs, rhs) } public func |(lhs: V, rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseOr.infix(lhs, rhs) + return Operator.bitwiseOr.infix(lhs, rhs) } public func ^(lhs: Expression, rhs: Expression) -> Expression where V.Datatype == Int64 { @@ -343,166 +343,166 @@ public func ^(lhs: V, rhs: Expression) -> Expression where V. } public prefix func ~(rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseXor.wrap(rhs) + return Operator.bitwiseXor.wrap(rhs) } public prefix func ~(rhs: Expression) -> Expression where V.Datatype == Int64 { - return Operators.bitwiseXor.wrap(rhs) + return Operator.bitwiseXor.wrap(rhs) } // MARK: - public func ==(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return Operators.eq.infix(lhs, rhs) + return Operator.eq.infix(lhs, rhs) } public func ==(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return Operators.eq.infix(lhs, rhs) + return Operator.eq.infix(lhs, rhs) } public func ==(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return Operators.eq.infix(lhs, rhs) + return Operator.eq.infix(lhs, rhs) } public func ==(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return Operators.eq.infix(lhs, rhs) + return Operator.eq.infix(lhs, rhs) } public func ==(lhs: Expression, rhs: V) -> Expression where V.Datatype : Equatable { - return Operators.eq.infix(lhs, rhs) + return Operator.eq.infix(lhs, rhs) } public func ==(lhs: Expression, rhs: V?) -> Expression where V.Datatype : Equatable { guard let rhs = rhs else { return "IS".infix(lhs, Expression(value: nil)) } - return Operators.eq.infix(lhs, rhs) + return Operator.eq.infix(lhs, rhs) } public func ==(lhs: V, rhs: Expression) -> Expression where V.Datatype : Equatable { - return Operators.eq.infix(lhs, rhs) + return Operator.eq.infix(lhs, rhs) } public func ==(lhs: V?, rhs: Expression) -> Expression where V.Datatype : Equatable { guard let lhs = lhs else { return "IS".infix(Expression(value: nil), rhs) } - return Operators.eq.infix(lhs, rhs) + return Operator.eq.infix(lhs, rhs) } public func !=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return Operators.neq.infix(lhs, rhs) + return Operator.neq.infix(lhs, rhs) } public func !=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return Operators.neq.infix(lhs, rhs) + return Operator.neq.infix(lhs, rhs) } public func !=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return Operators.neq.infix(lhs, rhs) + return Operator.neq.infix(lhs, rhs) } public func !=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Equatable { - return Operators.neq.infix(lhs, rhs) + return Operator.neq.infix(lhs, rhs) } public func !=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Equatable { - return Operators.neq.infix(lhs, rhs) + return Operator.neq.infix(lhs, rhs) } public func !=(lhs: Expression, rhs: V?) -> Expression where V.Datatype : Equatable { guard let rhs = rhs else { return "IS NOT".infix(lhs, Expression(value: nil)) } - return Operators.neq.infix(lhs, rhs) + return Operator.neq.infix(lhs, rhs) } public func !=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Equatable { - return Operators.neq.infix(lhs, rhs) + return Operator.neq.infix(lhs, rhs) } public func !=(lhs: V?, rhs: Expression) -> Expression where V.Datatype : Equatable { guard let lhs = lhs else { return "IS NOT".infix(Expression(value: nil), rhs) } - return Operators.neq.infix(lhs, rhs) + return Operator.neq.infix(lhs, rhs) } public func >(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.gt.infix(lhs, rhs) + return Operator.gt.infix(lhs, rhs) } public func >(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.gt.infix(lhs, rhs) + return Operator.gt.infix(lhs, rhs) } public func >(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.gt.infix(lhs, rhs) + return Operator.gt.infix(lhs, rhs) } public func >(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.gt.infix(lhs, rhs) + return Operator.gt.infix(lhs, rhs) } public func >(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return Operators.gt.infix(lhs, rhs) + return Operator.gt.infix(lhs, rhs) } public func >(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return Operators.gt.infix(lhs, rhs) + return Operator.gt.infix(lhs, rhs) } public func >(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.gt.infix(lhs, rhs) + return Operator.gt.infix(lhs, rhs) } public func >(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.gt.infix(lhs, rhs) + return Operator.gt.infix(lhs, rhs) } public func >=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.gte.infix(lhs, rhs) + return Operator.gte.infix(lhs, rhs) } public func >=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.gte.infix(lhs, rhs) + return Operator.gte.infix(lhs, rhs) } public func >=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.gte.infix(lhs, rhs) + return Operator.gte.infix(lhs, rhs) } public func >=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.gte.infix(lhs, rhs) + return Operator.gte.infix(lhs, rhs) } public func >=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return Operators.gte.infix(lhs, rhs) + return Operator.gte.infix(lhs, rhs) } public func >=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return Operators.gte.infix(lhs, rhs) + return Operator.gte.infix(lhs, rhs) } public func >=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.gte.infix(lhs, rhs) + return Operator.gte.infix(lhs, rhs) } public func >=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.gte.infix(lhs, rhs) + return Operator.gte.infix(lhs, rhs) } public func <(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.lt.infix(lhs, rhs) + return Operator.lt.infix(lhs, rhs) } public func <(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.lt.infix(lhs, rhs) + return Operator.lt.infix(lhs, rhs) } public func <(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.lt.infix(lhs, rhs) + return Operator.lt.infix(lhs, rhs) } public func <(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.lt.infix(lhs, rhs) + return Operator.lt.infix(lhs, rhs) } public func <(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return Operators.lt.infix(lhs, rhs) + return Operator.lt.infix(lhs, rhs) } public func <(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return Operators.lt.infix(lhs, rhs) + return Operator.lt.infix(lhs, rhs) } public func <(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.lt.infix(lhs, rhs) + return Operator.lt.infix(lhs, rhs) } public func <(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.lt.infix(lhs, rhs) + return Operator.lt.infix(lhs, rhs) } public func <=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.lte.infix(lhs, rhs) + return Operator.lte.infix(lhs, rhs) } public func <=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.lte.infix(lhs, rhs) + return Operator.lte.infix(lhs, rhs) } public func <=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.lte.infix(lhs, rhs) + return Operator.lte.infix(lhs, rhs) } public func <=(lhs: Expression, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.lte.infix(lhs, rhs) + return Operator.lte.infix(lhs, rhs) } public func <=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return Operators.lte.infix(lhs, rhs) + return Operator.lte.infix(lhs, rhs) } public func <=(lhs: Expression, rhs: V) -> Expression where V.Datatype : Comparable { - return Operators.lte.infix(lhs, rhs) + return Operator.lte.infix(lhs, rhs) } public func <=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.lte.infix(lhs, rhs) + return Operator.lte.infix(lhs, rhs) } public func <=(lhs: V, rhs: Expression) -> Expression where V.Datatype : Comparable { - return Operators.lte.infix(lhs, rhs) + return Operator.lte.infix(lhs, rhs) } public func ~=(lhs: ClosedRange, rhs: Expression) -> Expression where V.Datatype : Comparable & Value { @@ -548,58 +548,58 @@ public func ~=(lhs: PartialRangeFrom, rhs: Expression) -> Expr // MARK: - public func &&(lhs: Expression, rhs: Expression) -> Expression { - return Operators.and.infix(lhs, rhs) + return Operator.and.infix(lhs, rhs) } public func &&(lhs: Expression, rhs: Expression) -> Expression { - return Operators.and.infix(lhs, rhs) + return Operator.and.infix(lhs, rhs) } public func &&(lhs: Expression, rhs: Expression) -> Expression { - return Operators.and.infix(lhs, rhs) + return Operator.and.infix(lhs, rhs) } public func &&(lhs: Expression, rhs: Expression) -> Expression { - return Operators.and.infix(lhs, rhs) + return Operator.and.infix(lhs, rhs) } public func &&(lhs: Expression, rhs: Bool) -> Expression { - return Operators.and.infix(lhs, rhs) + return Operator.and.infix(lhs, rhs) } public func &&(lhs: Expression, rhs: Bool) -> Expression { - return Operators.and.infix(lhs, rhs) + return Operator.and.infix(lhs, rhs) } public func &&(lhs: Bool, rhs: Expression) -> Expression { - return Operators.and.infix(lhs, rhs) + return Operator.and.infix(lhs, rhs) } public func &&(lhs: Bool, rhs: Expression) -> Expression { - return Operators.and.infix(lhs, rhs) + return Operator.and.infix(lhs, rhs) } public func ||(lhs: Expression, rhs: Expression) -> Expression { - return Operators.or.infix(lhs, rhs) + return Operator.or.infix(lhs, rhs) } public func ||(lhs: Expression, rhs: Expression) -> Expression { - return Operators.or.infix(lhs, rhs) + return Operator.or.infix(lhs, rhs) } public func ||(lhs: Expression, rhs: Expression) -> Expression { - return Operators.or.infix(lhs, rhs) + return Operator.or.infix(lhs, rhs) } public func ||(lhs: Expression, rhs: Expression) -> Expression { - return Operators.or.infix(lhs, rhs) + return Operator.or.infix(lhs, rhs) } public func ||(lhs: Expression, rhs: Bool) -> Expression { - return Operators.or.infix(lhs, rhs) + return Operator.or.infix(lhs, rhs) } public func ||(lhs: Expression, rhs: Bool) -> Expression { - return Operators.or.infix(lhs, rhs) + return Operator.or.infix(lhs, rhs) } public func ||(lhs: Bool, rhs: Expression) -> Expression { - return Operators.or.infix(lhs, rhs) + return Operator.or.infix(lhs, rhs) } public func ||(lhs: Bool, rhs: Expression) -> Expression { - return Operators.or.infix(lhs, rhs) + return Operator.or.infix(lhs, rhs) } public prefix func !(rhs: Expression) -> Expression { - return Operators.not.wrap(rhs) + return Operator.not.wrap(rhs) } public prefix func !(rhs: Expression) -> Expression { - return Operators.not.wrap(rhs) + return Operator.not.wrap(rhs) }