mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
FetchRequest: SQLSupport cleanup
This commit is contained in:
1 parent
8cdacf3899
commit
d9626faaec
5 files changed
+158
-277
No files matched your search
@@ -41,7 +41,9 @@ extension FetchRequest {
|
||||
/// Returns a new FetchRequest with a new net of selected columns.
|
||||
@warn_unused_result
|
||||
public func select(selection: [_SQLSelectable]) -> FetchRequest<T> {
|
||||
return FetchRequest(query.select(selection))
|
||||
var query = self.query
|
||||
query.selection = selection
|
||||
return FetchRequest(query)
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with a new net of selected columns.
|
||||
@@ -61,7 +63,13 @@ extension FetchRequest {
|
||||
/// eventual set of already applied predicates.
|
||||
@warn_unused_result
|
||||
public func filter(predicate: _SQLExpressionType) -> FetchRequest<T> {
|
||||
return FetchRequest(query.filter(predicate.SQLExpression))
|
||||
var query = self.query
|
||||
if let whereExpression = query.whereExpression {
|
||||
query.whereExpression = .InfixOperator("AND", whereExpression, predicate.SQLExpression)
|
||||
} else {
|
||||
query.whereExpression = predicate.SQLExpression
|
||||
}
|
||||
return FetchRequest(query)
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with the provided *predicate* added to the
|
||||
@@ -80,7 +88,9 @@ extension FetchRequest {
|
||||
/// Returns a new FetchRequest grouped according to *expressions*.
|
||||
@warn_unused_result
|
||||
public func group(expressions: [_SQLExpressionType]) -> FetchRequest<T> {
|
||||
return FetchRequest(query.group(expressions.map { $0.SQLExpression }))
|
||||
var query = self.query
|
||||
query.groupByExpressions = expressions.map { $0.SQLExpression }
|
||||
return FetchRequest(query)
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with a new grouping.
|
||||
@@ -93,7 +103,13 @@ extension FetchRequest {
|
||||
/// eventual set of already applied predicates.
|
||||
@warn_unused_result
|
||||
public func having(predicate: _SQLExpressionType) -> FetchRequest<T> {
|
||||
return FetchRequest(query.having(predicate.SQLExpression))
|
||||
var query = self.query
|
||||
if let havingExpression = query.havingExpression {
|
||||
query.havingExpression = (havingExpression && predicate).SQLExpression
|
||||
} else {
|
||||
query.havingExpression = predicate.SQLExpression
|
||||
}
|
||||
return FetchRequest(query)
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with the provided *sql* added to
|
||||
@@ -114,7 +130,9 @@ extension FetchRequest {
|
||||
/// the eventual set of already applied sort descriptors.
|
||||
@warn_unused_result
|
||||
public func order(sortDescriptors: [_SQLSortDescriptorType]) -> FetchRequest<T> {
|
||||
return FetchRequest(query.order(sortDescriptors))
|
||||
var query = self.query
|
||||
query.sortDescriptors.appendContentsOf(sortDescriptors)
|
||||
return FetchRequest(query)
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with the provided *sql* added to the
|
||||
@@ -136,7 +154,9 @@ extension FetchRequest {
|
||||
/// *offset*.
|
||||
@warn_unused_result
|
||||
public func limit(limit: Int, offset: Int? = nil) -> FetchRequest<T> {
|
||||
return FetchRequest(query.limit(limit, offset: offset))
|
||||
var query = self.query
|
||||
query.limit = _SQLLimit(limit: limit, offset: offset)
|
||||
return FetchRequest(query)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,23 +76,15 @@ extension _DerivedSQLExpressionType {
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func == (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.Equal(
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
public func == (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .Collate(lhs.baseExpression == rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func == (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.Equal(
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
public func == (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _SQLExpression {
|
||||
return .Collate(lhs == rhs.baseExpression, rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
@@ -101,23 +93,15 @@ public func == (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQ
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func != (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.NotEqual(
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
public func != (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .Collate(lhs.baseExpression != rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func != (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.NotEqual(
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
public func != (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _SQLExpression {
|
||||
return .Collate(lhs != rhs.baseExpression, rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
@@ -126,23 +110,15 @@ public func != (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQ
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func < (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator("<",
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
public func < (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .Collate(lhs.baseExpression < rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func < (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator("<",
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
public func < (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _SQLExpression {
|
||||
return .Collate(lhs < rhs.baseExpression, rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
@@ -151,23 +127,15 @@ public func < (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQL
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func <= (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator("<=",
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
public func <= (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .Collate(lhs.baseExpression <= rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func <= (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator("<=",
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
public func <= (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _SQLExpression {
|
||||
return .Collate(lhs <= rhs.baseExpression, rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
@@ -176,23 +144,15 @@ public func <= (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQ
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func > (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator(">",
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
public func > (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .Collate(lhs.baseExpression > rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func > (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator(">",
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
public func > (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _SQLExpression {
|
||||
return .Collate(lhs > rhs.baseExpression, rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
@@ -201,23 +161,15 @@ public func > (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQL
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func >= (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator(">=",
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
public func >= (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .Collate(lhs.baseExpression >= rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func >= (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator(">=",
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
public func >= (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _SQLExpression {
|
||||
return .Collate(lhs >= rhs.baseExpression, rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
@@ -228,13 +180,8 @@ extension ClosedInterval where Bound: _SQLExpressionType {
|
||||
/// an interval.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.Between(
|
||||
value: element.baseExpression,
|
||||
min: start.SQLExpression,
|
||||
max: end.SQLExpression),
|
||||
element.collationName)
|
||||
public func contains(element: _CollatedExpression) -> _SQLExpression {
|
||||
return .Collate(contains(element.baseExpression), element.collationName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,18 +190,8 @@ extension HalfOpenInterval where Bound: _SQLExpressionType {
|
||||
/// an interval.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("AND",
|
||||
.Collate(
|
||||
.InfixOperator(">=",
|
||||
element.baseExpression,
|
||||
start.SQLExpression),
|
||||
element.collationName),
|
||||
.Collate(
|
||||
.InfixOperator("<",
|
||||
element.baseExpression,
|
||||
end.SQLExpression),
|
||||
element.collationName))
|
||||
public func contains(element: _CollatedExpression) -> _SQLExpression {
|
||||
return (element >= start) && (element < end)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,12 +203,8 @@ extension SequenceType where Self.Generator.Element: _SQLExpressionType {
|
||||
/// a sequence.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.In(
|
||||
map { $0.SQLExpression },
|
||||
element.baseExpression),
|
||||
element.collationName)
|
||||
public func contains(element: _CollatedExpression) -> _SQLExpression {
|
||||
return .Collate(contains(element.baseExpression), element.collationName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,23 +214,15 @@ extension SequenceType where Self.Generator.Element: _SQLExpressionType {
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func === (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.Is(
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
public func === (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .Collate(lhs.baseExpression === rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func === (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.Is(
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
public func === (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _SQLExpression {
|
||||
return .Collate(lhs == rhs.baseExpression, rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
@@ -306,21 +231,13 @@ public func === (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedS
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func !== (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.IsNot(
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
public func !== (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .Collate(lhs.baseExpression !== rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func !== (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.IsNot(
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
public func !== (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _SQLExpression {
|
||||
return .Collate(lhs !== rhs.baseExpression, rhs.collationName)
|
||||
}
|
||||
@@ -4,8 +4,8 @@ extension DatabaseFunction {
|
||||
/// Returns an SQL expression that applies the function.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func apply(arguments: _SQLExpressionType...) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function(name, arguments.map { $0.SQLExpression })
|
||||
public func apply(arguments: _SQLExpressionType...) -> _SQLExpression {
|
||||
return .Function(name, arguments.map { $0.SQLExpression })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ extension DatabaseFunction {
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func abs(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("ABS", [value.SQLExpression])
|
||||
public func abs(value: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Function("ABS", [value.SQLExpression])
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ public func abs(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func average(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("AVG", [value.SQLExpression])
|
||||
public func average(value: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Function("AVG", [value.SQLExpression])
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ public func average(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionTy
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func count(counted: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Count(counted)
|
||||
public func count(counted: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Count(counted)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ public func count(counted: _DerivedSQLExpressionType) -> _DerivedSQLExpressionTy
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func count(distinct value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.CountDistinct(value.SQLExpression)
|
||||
public func count(distinct value: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .CountDistinct(value.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
@@ -55,16 +55,16 @@ public func count(distinct value: _DerivedSQLExpressionType) -> _DerivedSQLExpre
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func ?? (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("IFNULL", [lhs.SQLExpression, rhs.SQLExpression])
|
||||
public func ?? (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .Function("IFNULL", [lhs.SQLExpression, rhs.SQLExpression])
|
||||
}
|
||||
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func ?? (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
public func ?? (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
if let lhs = lhs {
|
||||
return _SQLExpression.Function("IFNULL", [lhs.SQLExpression, rhs.SQLExpression])
|
||||
return .Function("IFNULL", [lhs.SQLExpression, rhs.SQLExpression])
|
||||
} else {
|
||||
return rhs.SQLExpression
|
||||
}
|
||||
@@ -77,8 +77,8 @@ extension _DerivedSQLExpressionType {
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public var lowercaseString: _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("LOWER", [SQLExpression])
|
||||
public var lowercaseString: _SQLExpression {
|
||||
return .Function("LOWER", [SQLExpression])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ extension _DerivedSQLExpressionType {
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func max(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("MAX", [value.SQLExpression])
|
||||
public func max(value: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Function("MAX", [value.SQLExpression])
|
||||
}
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ public func max(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func min(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("MIN", [value.SQLExpression])
|
||||
public func min(value: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Function("MIN", [value.SQLExpression])
|
||||
}
|
||||
|
||||
|
||||
@@ -108,8 +108,8 @@ public func min(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func sum(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("SUM", [value.SQLExpression])
|
||||
public func sum(value: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Function("SUM", [value.SQLExpression])
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ extension _DerivedSQLExpressionType {
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public var uppercaseString: _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("UPPER", [SQLExpression])
|
||||
public var uppercaseString: _SQLExpression {
|
||||
return .Function("UPPER", [SQLExpression])
|
||||
}
|
||||
}
|
||||
@@ -3,22 +3,22 @@
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func == (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType?) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Equal(lhs.SQLExpression, rhs?.SQLExpression ?? .Value(nil))
|
||||
public func == (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType?) -> _SQLExpression {
|
||||
return .Equal(lhs.SQLExpression, rhs?.SQLExpression ?? .Value(nil))
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func == (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Equal(lhs?.SQLExpression ?? .Value(nil), rhs.SQLExpression)
|
||||
public func == (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Equal(lhs?.SQLExpression ?? .Value(nil), rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func == (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Equal(lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func == (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Equal(lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,22 +27,22 @@ public func == (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType)
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func != (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType?) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.NotEqual(lhs.SQLExpression, rhs?.SQLExpression ?? .Value(nil))
|
||||
public func != (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType?) -> _SQLExpression {
|
||||
return .NotEqual(lhs.SQLExpression, rhs?.SQLExpression ?? .Value(nil))
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func != (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.NotEqual(lhs?.SQLExpression ?? .Value(nil), rhs.SQLExpression)
|
||||
public func != (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .NotEqual(lhs?.SQLExpression ?? .Value(nil), rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func != (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.NotEqual(lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func != (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .NotEqual(lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,22 +51,22 @@ public func != (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType)
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func < (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("<", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func < (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("<", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func < (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("<", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func < (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("<", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func < (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("<", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func < (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("<", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
@@ -75,22 +75,22 @@ public func < (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func <= (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("<=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func <= (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("<=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func <= (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("<=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func <= (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("<=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func <= (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("<=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func <= (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("<=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
@@ -99,22 +99,22 @@ public func <= (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType)
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func > (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator(">", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func > (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator(">", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func > (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator(">", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func > (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator(">", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func > (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator(">", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func > (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator(">", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
@@ -123,22 +123,22 @@ public func > (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func >= (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator(">=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func >= (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator(">=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func >= (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator(">=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func >= (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator(">=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func >= (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator(">=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func >= (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator(">=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
@@ -253,22 +253,22 @@ public func - (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func && (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("AND", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func && (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("AND", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func && (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("AND", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func && (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("AND", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func && (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("AND", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func && (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("AND", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
@@ -279,8 +279,8 @@ extension Range where Element: protocol<_SQLExpressionType, BidirectionalIndexTy
|
||||
/// a range.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Between(value: element.SQLExpression, min: startIndex.SQLExpression, max: endIndex.predecessor().SQLExpression)
|
||||
public func contains(element: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Between(value: element.SQLExpression, min: startIndex.SQLExpression, max: endIndex.predecessor().SQLExpression)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,8 +289,8 @@ extension ClosedInterval where Bound: _SQLExpressionType {
|
||||
/// an interval.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Between(value: element.SQLExpression, min: start.SQLExpression, max: end.SQLExpression)
|
||||
public func contains(element: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Between(value: element.SQLExpression, min: start.SQLExpression, max: end.SQLExpression)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,8 +299,8 @@ extension HalfOpenInterval where Bound: _SQLExpressionType {
|
||||
/// an interval.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("AND", .InfixOperator(">=", element.SQLExpression, start.SQLExpression), .InfixOperator("<", element.SQLExpression, end.SQLExpression))
|
||||
public func contains(element: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return (element >= start) && (element < end)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,8 +312,8 @@ extension SequenceType where Self.Generator.Element: _SQLExpressionType {
|
||||
/// a sequence.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.In(map { $0.SQLExpression }, element.SQLExpression)
|
||||
public func contains(element: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .In(map { $0.SQLExpression }, element.SQLExpression)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,22 +323,22 @@ extension SequenceType where Self.Generator.Element: _SQLExpressionType {
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func === (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType?) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Is(lhs.SQLExpression, rhs?.SQLExpression ?? .Value(nil))
|
||||
public func === (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType?) -> _SQLExpression {
|
||||
return .Is(lhs.SQLExpression, rhs?.SQLExpression ?? .Value(nil))
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func === (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Is(lhs?.SQLExpression ?? .Value(nil), rhs.SQLExpression)
|
||||
public func === (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Is(lhs?.SQLExpression ?? .Value(nil), rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func === (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Is(lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func === (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Is(lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
@@ -347,22 +347,22 @@ public func === (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType)
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func !== (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType?) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.IsNot(lhs.SQLExpression, rhs?.SQLExpression ?? .Value(nil))
|
||||
public func !== (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType?) -> _SQLExpression {
|
||||
return .IsNot(lhs.SQLExpression, rhs?.SQLExpression ?? .Value(nil))
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func !== (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.IsNot(lhs?.SQLExpression ?? .Value(nil), rhs.SQLExpression)
|
||||
public func !== (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .IsNot(lhs?.SQLExpression ?? .Value(nil), rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func !== (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.IsNot(lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func !== (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .IsNot(lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
@@ -371,22 +371,22 @@ public func !== (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType)
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func || (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("OR", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func || (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("OR", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func || (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("OR", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func || (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("OR", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func || (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("OR", lhs.SQLExpression, rhs.SQLExpression)
|
||||
public func || (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("OR", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
@@ -395,6 +395,6 @@ public func || (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType)
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public prefix func ! (value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Not(value.SQLExpression)
|
||||
public prefix func ! (value: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .Not(value.SQLExpression)
|
||||
}
|
||||
@@ -87,62 +87,6 @@ struct _SQLQuery {
|
||||
}
|
||||
|
||||
|
||||
// MARK: - _SQLQuery derivation
|
||||
|
||||
extension _SQLQuery {
|
||||
|
||||
@warn_unused_result
|
||||
func select(selection: [_SQLSelectable]) -> _SQLQuery {
|
||||
var query = self
|
||||
query.selection = selection
|
||||
return query
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
func filter(predicate: _SQLExpression) -> _SQLQuery {
|
||||
var query = self
|
||||
if let whereExpression = query.whereExpression {
|
||||
query.whereExpression = .InfixOperator("AND", whereExpression, predicate)
|
||||
} else {
|
||||
query.whereExpression = predicate
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
func group(expressions: [_SQLExpression]) -> _SQLQuery {
|
||||
var query = self
|
||||
query.groupByExpressions = expressions
|
||||
return query
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
func having(predicate: _SQLExpression) -> _SQLQuery {
|
||||
var query = self
|
||||
if let havingExpression = query.havingExpression {
|
||||
query.havingExpression = .InfixOperator("AND", havingExpression, predicate)
|
||||
} else {
|
||||
query.havingExpression = predicate
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
func order(sortDescriptors: [_SQLSortDescriptorType]) -> _SQLQuery {
|
||||
var query = self
|
||||
query.sortDescriptors.appendContentsOf(sortDescriptors)
|
||||
return query
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
func limit(limit: Int, offset: Int?) -> _SQLQuery {
|
||||
var query = self
|
||||
query.limit = _SQLLimit(limit: limit, offset: offset)
|
||||
return query
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - _SQLSource
|
||||
|
||||
indirect enum _SQLSource {
|
||||
|
||||
Reference in new issue
Block a user