mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
Simplify handling of collated expressions
This commit is contained in:
1 parent
fcff9b34ba
commit
c4f9ddd688
10 files changed
+64
-346
No files matched your search
@@ -42,8 +42,6 @@
|
||||
5605F1731C672E4000235C62 /* StandardLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1581C672E4000235C62 /* StandardLibrary.swift */; };
|
||||
5605F1741C672E4000235C62 /* StandardLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1581C672E4000235C62 /* StandardLibrary.swift */; };
|
||||
5605F1881C69111300235C62 /* DatabaseRegionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1861C69111300235C62 /* DatabaseRegionTests.swift */; };
|
||||
5605F18D1C6B1A8700235C62 /* SQLCollatedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */; };
|
||||
5605F18E1C6B1A8700235C62 /* SQLCollatedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */; };
|
||||
560714E3227DD0810091BB10 /* AssociationPrefetchingSQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560714E2227DD0810091BB10 /* AssociationPrefetchingSQLTests.swift */; };
|
||||
560714E4227DD0810091BB10 /* AssociationPrefetchingSQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560714E2227DD0810091BB10 /* AssociationPrefetchingSQLTests.swift */; };
|
||||
5607EFD41BB827FD00605DE3 /* TransactionObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5607EFD21BB8254800605DE3 /* TransactionObserverTests.swift */; };
|
||||
@@ -370,7 +368,6 @@
|
||||
565490D81D5AE252005622CB /* DatabaseMigrator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238921B9C750B0082EB20 /* DatabaseMigrator.swift */; };
|
||||
565490D91D5AE252005622CB /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4391BEB42D500E39BBF /* Migration.swift */; };
|
||||
565490DA1D5AE252005622CB /* QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B6F1C53F592005A543B /* QueryInterfaceRequest.swift */; };
|
||||
565490DB1D5AE252005622CB /* SQLCollatedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */; };
|
||||
565490DF1D5AE252005622CB /* TableDefinition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566AD8B11D5318F4002EC1A8 /* TableDefinition.swift */; };
|
||||
565490E11D5AE252005622CB /* PersistableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560D92441C672C4B00F4F92B /* PersistableRecord.swift */; };
|
||||
565490E21D5AE252005622CB /* Record.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238A11B9C753B0082EB20 /* Record.swift */; };
|
||||
@@ -905,7 +902,6 @@
|
||||
AAA4DC7B230F1E0600C74B15 /* TableRecord+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8AA2295BFD6001FF3FF /* TableRecord+QueryInterfaceRequest.swift */; };
|
||||
AAA4DC7C230F1E0600C74B15 /* SQLExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5421EAA359A00BFAF62 /* SQLExpression.swift */; };
|
||||
AAA4DC7D230F1E0600C74B15 /* EncodableRecord+Encodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5674A6F31F307F600095F066 /* EncodableRecord+Encodable.swift */; };
|
||||
AAA4DC7E230F1E0600C74B15 /* SQLCollatedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */; };
|
||||
AAA4DC7F230F1E0600C74B15 /* SQLOperators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566475CB1D981D5E00FF74B8 /* SQLOperators.swift */; };
|
||||
AAA4DC80230F1E0600C74B15 /* FTS5CustomTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */; };
|
||||
AAA4DC81230F1E0600C74B15 /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFA20944C7B00F46237 /* Association.swift */; };
|
||||
@@ -1252,7 +1248,6 @@
|
||||
5605F1571C672E4000235C62 /* DatabaseValueConvertible+RawRepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DatabaseValueConvertible+RawRepresentable.swift"; sourceTree = "<group>"; };
|
||||
5605F1581C672E4000235C62 /* StandardLibrary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StandardLibrary.swift; sourceTree = "<group>"; };
|
||||
5605F1861C69111300235C62 /* DatabaseRegionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRegionTests.swift; sourceTree = "<group>"; };
|
||||
5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLCollatedExpression.swift; sourceTree = "<group>"; };
|
||||
560714E2227DD0810091BB10 /* AssociationPrefetchingSQLTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssociationPrefetchingSQLTests.swift; sourceTree = "<group>"; };
|
||||
5607EFD21BB8254800605DE3 /* TransactionObserverTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransactionObserverTests.swift; sourceTree = "<group>"; };
|
||||
560A37A31C8F625000949E71 /* DatabasePool.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabasePool.swift; sourceTree = "<group>"; };
|
||||
@@ -2040,7 +2035,6 @@
|
||||
56CEB5401EAA359A00BFAF62 /* Column.swift */,
|
||||
56D91AA82205F2F000770D8D /* DatabasePromise.swift */,
|
||||
5656A81D2295B12F001FF3FF /* SQLAssociation.swift */,
|
||||
5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */,
|
||||
566475991D97D8A000FF74B8 /* SQLCollection.swift */,
|
||||
56CEB5421EAA359A00BFAF62 /* SQLExpression.swift */,
|
||||
5653EAF920944C7B00F46237 /* SQLForeignKeyRequest.swift */,
|
||||
@@ -2943,7 +2937,6 @@
|
||||
5653EC142098738B00F46237 /* SQLGenerationContext.swift in Sources */,
|
||||
563B8F94249E6171007A48C9 /* Trace.swift in Sources */,
|
||||
568D13212207213F00674B58 /* SQLQueryGenerator.swift in Sources */,
|
||||
565490DB1D5AE252005622CB /* SQLCollatedExpression.swift in Sources */,
|
||||
5674A7071F307FCD0095F066 /* DatabaseValueConvertible+ReferenceConvertible.swift in Sources */,
|
||||
565490C61D5AE236005622CB /* Statement.swift in Sources */,
|
||||
56CEB5071EAA2F4D00BFAF62 /* FTS4.swift in Sources */,
|
||||
@@ -3015,7 +3008,6 @@
|
||||
5656A8B12295BFD7001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */,
|
||||
56CEB5561EAA359A00BFAF62 /* SQLExpression.swift in Sources */,
|
||||
5674A6F91F307F600095F066 /* EncodableRecord+Encodable.swift in Sources */,
|
||||
5605F18E1C6B1A8700235C62 /* SQLCollatedExpression.swift in Sources */,
|
||||
566475D61D981D5E00FF74B8 /* SQLOperators.swift in Sources */,
|
||||
5698AD381DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */,
|
||||
56012BA8257404E000B4925B /* CommonTableExpression.swift in Sources */,
|
||||
@@ -3602,7 +3594,6 @@
|
||||
AAA4DC7B230F1E0600C74B15 /* TableRecord+QueryInterfaceRequest.swift in Sources */,
|
||||
AAA4DC7C230F1E0600C74B15 /* SQLExpression.swift in Sources */,
|
||||
AAA4DC7D230F1E0600C74B15 /* EncodableRecord+Encodable.swift in Sources */,
|
||||
AAA4DC7E230F1E0600C74B15 /* SQLCollatedExpression.swift in Sources */,
|
||||
AAA4DC7F230F1E0600C74B15 /* SQLOperators.swift in Sources */,
|
||||
AAA4DC80230F1E0600C74B15 /* FTS5CustomTokenizer.swift in Sources */,
|
||||
56012BB2257404E200B4925B /* CommonTableExpression.swift in Sources */,
|
||||
@@ -3974,7 +3965,6 @@
|
||||
56300B781C53F592005A543B /* QueryInterfaceRequest.swift in Sources */,
|
||||
568ECA8A25D7013000B71526 /* SQLSelection.swift in Sources */,
|
||||
56AACAA822ACED7100A40F2A /* Fetch.swift in Sources */,
|
||||
5605F18D1C6B1A8700235C62 /* SQLCollatedExpression.swift in Sources */,
|
||||
566B91331FA4D3810012D5B0 /* TransactionObserver.swift in Sources */,
|
||||
566475D31D981D5E00FF74B8 /* SQLOperators.swift in Sources */,
|
||||
56CEB4FA1EAA2F4D00BFAF62 /* FTS3.swift in Sources */,
|
||||
|
||||
@@ -232,6 +232,9 @@ extension SQL {
|
||||
@available(*, unavailable, renamed: "SQLExpression.AssociativeBinaryOperator")
|
||||
typealias SQLLogicalBinaryOperator = SQLExpression.AssociativeBinaryOperator
|
||||
|
||||
@available(*, deprecated, renamed: "SQLExpression")
|
||||
typealias SQLCollatedExpression = SQLExpression
|
||||
|
||||
extension SQLRequest {
|
||||
@available(*, unavailable, renamed: "RowDecoder")
|
||||
typealias T = RowDecoder
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
/// SQLCollatedExpression taints an expression so that every derived expression
|
||||
/// is eventually evaluated using an SQLite collation.
|
||||
///
|
||||
/// You create one by calling the `collating()` method:
|
||||
///
|
||||
/// let email = Column("email").collating(.nocase)
|
||||
///
|
||||
/// // SELECT * FROM player WHERE email = 'arthur@example.com' COLLATE NOCASE
|
||||
/// Player.filter(email == "arthur@example.com")
|
||||
public struct SQLCollatedExpression: SQLOrderingTerm {
|
||||
/// The tainted expression
|
||||
public let expression: SQLExpression
|
||||
|
||||
/// The name of the collation
|
||||
public let collationName: Database.CollationName
|
||||
|
||||
/// Returns an ordering suitable for QueryInterfaceRequest.order()
|
||||
///
|
||||
/// let email: SQLCollatedExpression = Column("email").collating(.nocase)
|
||||
///
|
||||
/// // SELECT * FROM player ORDER BY email COLLATE NOCASE ASC
|
||||
/// Player.order(email.asc)
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var asc: SQLOrdering {
|
||||
.asc(sqlExpression)
|
||||
}
|
||||
|
||||
/// Returns an ordering suitable for QueryInterfaceRequest.order()
|
||||
///
|
||||
/// let email: SQLCollatedExpression = Column("email").collating(.nocase)
|
||||
///
|
||||
/// // SELECT * FROM player ORDER BY email COLLATE NOCASE DESC
|
||||
/// Player.order(email.desc)
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var desc: SQLOrdering {
|
||||
.desc(sqlExpression)
|
||||
}
|
||||
|
||||
#if GRDBCUSTOMSQLITE
|
||||
/// Returns an ordering suitable for QueryInterfaceRequest.order()
|
||||
///
|
||||
/// let email: SQLCollatedExpression = Column("email").collating(.nocase)
|
||||
///
|
||||
/// // SELECT * FROM player ORDER BY email COLLATE NOCASE ASC NULLS LAST
|
||||
/// Player.order(email.ascNullsLast)
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var ascNullsLast: SQLOrdering {
|
||||
.ascNullsLast(sqlExpression)
|
||||
}
|
||||
|
||||
/// Returns an ordering suitable for QueryInterfaceRequest.order()
|
||||
///
|
||||
/// let email: SQLCollatedExpression = Column("email").collating(.nocase)
|
||||
///
|
||||
/// // SELECT * FROM player ORDER BY email COLLATE NOCASE DESC NULLS FIRST
|
||||
/// Player.order(email.descNullsFirst)
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var descNullsFirst: SQLOrdering {
|
||||
.descNullsFirst(sqlExpression)
|
||||
}
|
||||
#elseif !GRDBCIPHER
|
||||
/// Returns an ordering suitable for QueryInterfaceRequest.order()
|
||||
///
|
||||
/// let email: SQLCollatedExpression = Column("email").collating(.nocase)
|
||||
///
|
||||
/// // SELECT * FROM player ORDER BY email COLLATE NOCASE ASC NULLS LAST
|
||||
/// Player.order(email.ascNullsLast)
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
@available(OSX 10.16, iOS 14, tvOS 14, watchOS 7, *)
|
||||
public var ascNullsLast: SQLOrdering {
|
||||
.ascNullsLast(sqlExpression)
|
||||
}
|
||||
|
||||
/// Returns an ordering suitable for QueryInterfaceRequest.order()
|
||||
///
|
||||
/// let email: SQLCollatedExpression = Column("email").collating(.nocase)
|
||||
///
|
||||
/// // SELECT * FROM player ORDER BY email COLLATE NOCASE DESC NULLS FIRST
|
||||
/// Player.order(email.descNullsFirst)
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
@available(OSX 10.16, iOS 14, tvOS 14, watchOS 7, *)
|
||||
public var descNullsFirst: SQLOrdering {
|
||||
.descNullsFirst(sqlExpression)
|
||||
}
|
||||
#endif
|
||||
|
||||
init(_ expression: SQLExpression, collationName: Database.CollationName) {
|
||||
self.expression = expression
|
||||
self.collationName = collationName
|
||||
}
|
||||
|
||||
var sqlExpression: SQLExpression {
|
||||
.collated(expression, collationName)
|
||||
}
|
||||
|
||||
public var sqlOrdering: SQLOrdering {
|
||||
.expression(sqlExpression)
|
||||
}
|
||||
}
|
||||
@@ -103,15 +103,12 @@ extension SQLCollection {
|
||||
guard let expression = expressions.first else {
|
||||
return false.sqlExpression
|
||||
}
|
||||
|
||||
// With SQLite, `expr IN (NULL)` never succeeds.
|
||||
//
|
||||
// We must not provide special handling of NULL, because we can not
|
||||
// guess if our `expressions` array contains a value evaluates to NULL.
|
||||
|
||||
|
||||
if expressions.count == 1 {
|
||||
// Output `expr = value` instead of `expr IN (value)`, because it
|
||||
// looks nicer. And make sure we do not produce 'expr IS NULL'.
|
||||
// Output `value = expression` instead of `value IN (expression)`,
|
||||
// because it looks nicer. Force the equal `=` operator, so that
|
||||
// the result evaluates just as `value IN (expression)`, even
|
||||
// if expression is NULL.
|
||||
return .compare(.equal, value, expression)
|
||||
}
|
||||
|
||||
|
||||
@@ -422,11 +422,22 @@ extension SQLExpression {
|
||||
upperBound: SQLExpression,
|
||||
isNegated: Bool = false) -> Self
|
||||
{
|
||||
self.init(impl: .between(
|
||||
expression: expression,
|
||||
lowerBound: lowerBound,
|
||||
upperBound: upperBound,
|
||||
isNegated: isNegated))
|
||||
if case let .collated(expression, collationName) = expression.impl {
|
||||
// Prefer: expression BETWEEN lowerBound AND upperBound COLLATE collation
|
||||
// over: (expression COLLATE collation) BETWEEN lowerBound AND upperBound
|
||||
return collated(between(
|
||||
expression: expression,
|
||||
lowerBound: lowerBound,
|
||||
upperBound: upperBound,
|
||||
isNegated: isNegated),
|
||||
collationName)
|
||||
} else {
|
||||
return self.init(impl: .between(
|
||||
expression: expression,
|
||||
lowerBound: lowerBound,
|
||||
upperBound: upperBound,
|
||||
isNegated: isNegated))
|
||||
}
|
||||
}
|
||||
|
||||
/// A binary operator.
|
||||
@@ -435,7 +446,17 @@ extension SQLExpression {
|
||||
/// <lhs> <= <rhs>
|
||||
/// <lhs> LIKE <rhs>
|
||||
static func binary(_ op: BinaryOperator, _ lhs: SQLExpression, _ rhs: SQLExpression) -> Self {
|
||||
self.init(impl: .binary(op, lhs, rhs))
|
||||
if case let .collated(lhs, collationName) = lhs.impl {
|
||||
// Prefer: lhs <= rhs COLLATE collation
|
||||
// over: (lhs COLLATE collation) <= rhs
|
||||
return collated(binary(op, lhs, rhs), collationName)
|
||||
} else if case let .collated(rhs, collationName) = rhs.impl {
|
||||
// Prefer: lhs <= rhs COLLATE collation
|
||||
// over: lhs <= (rhs COLLATE collation)
|
||||
return collated(binary(op, lhs, rhs), collationName)
|
||||
} else {
|
||||
return self.init(impl: .binary(op, lhs, rhs))
|
||||
}
|
||||
}
|
||||
|
||||
/// An associative binary operator.
|
||||
@@ -508,7 +529,17 @@ extension SQLExpression {
|
||||
///
|
||||
/// See also `SQLExpression.equal(_:_:)`.
|
||||
static func compare(_ op: EqualityOperator, _ lhs: SQLExpression, _ rhs: SQLExpression) -> Self {
|
||||
self.init(impl: .compare(op, lhs, rhs))
|
||||
if case let .collated(lhs, collationName) = lhs.impl {
|
||||
// Prefer: lhs = rhs COLLATE collation
|
||||
// over: (lhs COLLATE collation) = rhs
|
||||
return collated(compare(op, lhs, rhs), collationName)
|
||||
} else if case let .collated(rhs, collationName) = rhs.impl {
|
||||
// Prefer: lhs = rhs COLLATE collation
|
||||
// over: lhs = (rhs COLLATE collation)
|
||||
return collated(compare(op, lhs, rhs), collationName)
|
||||
} else {
|
||||
return self.init(impl: .compare(op, lhs, rhs))
|
||||
}
|
||||
}
|
||||
|
||||
/// An equality comparison. Null database values are checked with `IS NULL`.
|
||||
@@ -521,10 +552,10 @@ extension SQLExpression {
|
||||
case let (impl, .databaseValue(.null)),
|
||||
let (.databaseValue(.null), impl):
|
||||
// ... IS NULL
|
||||
return .compare(.is, SQLExpression(impl: impl), .null)
|
||||
return compare(.is, SQLExpression(impl: impl), .null)
|
||||
default:
|
||||
// lhs = rhs
|
||||
return .compare(.equal, lhs, rhs)
|
||||
return compare(.equal, lhs, rhs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,14 +589,14 @@ extension SQLExpression {
|
||||
///
|
||||
/// COUNT(<expression>)
|
||||
static func count(_ expression: SQLExpression) -> Self {
|
||||
.aggregate("COUNT", [expression])
|
||||
aggregate("COUNT", [expression])
|
||||
}
|
||||
|
||||
/// The `COUNT(DISTINCT)` function.
|
||||
///
|
||||
/// COUNT(DISTINCT <expression>)
|
||||
static func countDistinct(_ expression: SQLExpression) -> Self {
|
||||
.distinctAggregate("COUNT", expression)
|
||||
distinctAggregate("COUNT", expression)
|
||||
}
|
||||
|
||||
/// A function call.
|
||||
@@ -1679,8 +1710,8 @@ extension SQLSpecificExpressible {
|
||||
/// For example:
|
||||
///
|
||||
/// Player.filter(Column("email").collating(.nocase) == "contact@example.com")
|
||||
public func collating(_ collation: Database.CollationName) -> SQLCollatedExpression {
|
||||
SQLCollatedExpression(sqlExpression, collationName: collation)
|
||||
public func collating(_ collation: Database.CollationName) -> SQLExpression {
|
||||
.collated(sqlExpression, collation)
|
||||
}
|
||||
|
||||
/// Returns a collated expression.
|
||||
@@ -1688,7 +1719,7 @@ extension SQLSpecificExpressible {
|
||||
/// For example:
|
||||
///
|
||||
/// Player.filter(Column("name").collating(.localizedStandardCompare) == "Hervé")
|
||||
public func collating(_ collation: DatabaseCollation) -> SQLCollatedExpression {
|
||||
SQLCollatedExpression(sqlExpression, collationName: Database.CollationName(rawValue: collation.name))
|
||||
public func collating(_ collation: DatabaseCollation) -> SQLExpression {
|
||||
.collated(sqlExpression, Database.CollationName(rawValue: collation.name))
|
||||
}
|
||||
}
|
||||
@@ -13,19 +13,6 @@ public func == (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpress
|
||||
.equal(lhs.sqlExpression, rhs?.sqlExpression ?? .null)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `=` SQL operator.
|
||||
///
|
||||
/// // name = 'Arthur' COLLATE NOCASE
|
||||
/// Column("name").collating(.nocase) == "Arthur"
|
||||
///
|
||||
/// When the right operand is nil, `IS NULL` is used instead.
|
||||
///
|
||||
/// // name IS NULL
|
||||
/// Column("name").collating(.nocase) == nil
|
||||
public func == (lhs: SQLCollatedExpression, rhs: SQLExpressible?) -> SQLExpression {
|
||||
.collated(lhs.expression == rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that checks the boolean value of an expression.
|
||||
///
|
||||
/// The comparison is done with the built-in boolean evaluation of SQLite:
|
||||
@@ -56,19 +43,6 @@ public func == (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpress
|
||||
.equal(lhs?.sqlExpression ?? .null, rhs.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `=` SQL operator.
|
||||
///
|
||||
/// // 'Arthur' = name COLLATE NOCASE
|
||||
/// "Arthur" == Column("name").collating(.nocase)
|
||||
///
|
||||
/// When the left operand is nil, `IS NULL` is used instead.
|
||||
///
|
||||
/// // name IS NULL
|
||||
/// nil == Column("name").collating(.nocase)
|
||||
public func == (lhs: SQLExpressible?, rhs: SQLCollatedExpression) -> SQLExpression {
|
||||
.collated(lhs == rhs.expression, rhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that checks the boolean value of an expression.
|
||||
///
|
||||
/// The comparison is done with the built-in boolean evaluation of SQLite:
|
||||
@@ -107,19 +81,6 @@ public func != (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpress
|
||||
!(lhs == rhs)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<>` SQL operator.
|
||||
///
|
||||
/// // name <> 'Arthur' COLLATE NOCASE
|
||||
/// Column("name").collating(.nocase) != "Arthur"
|
||||
///
|
||||
/// When the right operand is nil, `IS NOT NULL` is used instead.
|
||||
///
|
||||
/// // name IS NOT NULL
|
||||
/// Column("name").collating(.nocase) != nil
|
||||
public func != (lhs: SQLCollatedExpression, rhs: SQLExpressible?) -> SQLExpression {
|
||||
!(lhs == rhs)
|
||||
}
|
||||
|
||||
/// An SQL expression that checks the boolean value of an expression.
|
||||
///
|
||||
/// The comparison is done with the built-in boolean evaluation of SQLite:
|
||||
@@ -146,19 +107,6 @@ public func != (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpress
|
||||
!(lhs == rhs)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<>` SQL operator.
|
||||
///
|
||||
/// // 'Arthur' <> name COLLATE NOCASE
|
||||
/// "Arthur" != Column("name").collating(.nocase)
|
||||
///
|
||||
/// When the left operand is nil, `IS NOT NULL` is used instead.
|
||||
///
|
||||
/// // name IS NOT NULL
|
||||
/// nil != Column("name").collating(.nocase)
|
||||
public func != (lhs: SQLExpressible?, rhs: SQLCollatedExpression) -> SQLExpression {
|
||||
!(lhs == rhs)
|
||||
}
|
||||
|
||||
/// An SQL expression that checks the boolean value of an expression.
|
||||
///
|
||||
/// The comparison is done with the built-in boolean evaluation of SQLite:
|
||||
@@ -188,14 +136,6 @@ public func === (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpres
|
||||
.compare(.is, lhs.sqlExpression, rhs?.sqlExpression ?? .null)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `IS` SQL operator.
|
||||
///
|
||||
/// // name IS 'Arthur' COLLATE NOCASE
|
||||
/// Column("name").collating(.nocase) === "Arthur"
|
||||
public func === (lhs: SQLCollatedExpression, rhs: SQLExpressible?) -> SQLExpression {
|
||||
.collated(lhs.expression === rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `IS` SQL operator.
|
||||
///
|
||||
/// // name IS 'Arthur'
|
||||
@@ -208,14 +148,6 @@ public func === (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpres
|
||||
}
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `IS` SQL operator.
|
||||
///
|
||||
/// // name IS 'Arthur' COLLATE NOCASE
|
||||
/// "Arthur" === Column("name").collating(.nocase)
|
||||
public func === (lhs: SQLExpressible?, rhs: SQLCollatedExpression) -> SQLExpression {
|
||||
.collated(lhs === rhs.expression, rhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `IS` SQL operator.
|
||||
///
|
||||
/// // email IS login
|
||||
@@ -232,14 +164,6 @@ public func !== (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpres
|
||||
!(lhs === rhs)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `IS NOT` SQL operator.
|
||||
///
|
||||
/// // name IS NOT 'Arthur' COLLATE NOCASE
|
||||
/// Column("name").collating(.nocase) !== "Arthur"
|
||||
public func !== (lhs: SQLCollatedExpression, rhs: SQLExpressible?) -> SQLExpression {
|
||||
!(lhs === rhs)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `IS NOT` SQL operator.
|
||||
///
|
||||
/// // name IS NOT 'Arthur'
|
||||
@@ -248,14 +172,6 @@ public func !== (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpres
|
||||
!(lhs === rhs)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `IS NOT` SQL operator.
|
||||
///
|
||||
/// // name IS NOT 'Arthur' COLLATE NOCASE
|
||||
/// "Arthur" !== Column("name").collating(.nocase)
|
||||
public func !== (lhs: SQLExpressible?, rhs: SQLCollatedExpression) -> SQLExpression {
|
||||
!(lhs === rhs)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `IS NOT` SQL operator.
|
||||
///
|
||||
/// // email IS NOT login
|
||||
@@ -274,14 +190,6 @@ public func < (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpressio
|
||||
.binary(.lessThan, lhs.sqlExpression, rhs.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<` SQL operator.
|
||||
///
|
||||
/// // name < 'Arthur' COLLATE NOCASE
|
||||
/// Column("name").collating(.nocase) < "Arthur"
|
||||
public func < (lhs: SQLCollatedExpression, rhs: SQLExpressible) -> SQLExpression {
|
||||
.collated(lhs.expression < rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<` SQL operator.
|
||||
///
|
||||
/// // 18 < score
|
||||
@@ -290,14 +198,6 @@ public func < (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpressio
|
||||
.binary(.lessThan, lhs.sqlExpression, rhs.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<` SQL operator.
|
||||
///
|
||||
/// // 'Arthur' < name COLLATE NOCASE
|
||||
/// "Arthur" < Column("name").collating(.nocase)
|
||||
public func < (lhs: SQLExpressible, rhs: SQLCollatedExpression) -> SQLExpression {
|
||||
.collated(lhs < rhs.expression, rhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<` SQL operator.
|
||||
///
|
||||
/// // width < height
|
||||
@@ -314,14 +214,6 @@ public func <= (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpressi
|
||||
.binary(.lessThanOrEqual, lhs.sqlExpression, rhs.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<=` SQL operator.
|
||||
///
|
||||
/// // name <= 'Arthur' COLLATE NOCASE
|
||||
/// Column("name").collating(.nocase) <= "Arthur"
|
||||
public func <= (lhs: SQLCollatedExpression, rhs: SQLExpressible) -> SQLExpression {
|
||||
.collated(lhs.expression <= rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<=` SQL operator.
|
||||
///
|
||||
/// // 18 <= score
|
||||
@@ -330,14 +222,6 @@ public func <= (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpressi
|
||||
.binary(.lessThanOrEqual, lhs.sqlExpression, rhs.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<=` SQL operator.
|
||||
///
|
||||
/// // 'Arthur' <= name COLLATE NOCASE
|
||||
/// "Arthur" <= Column("name").collating(.nocase)
|
||||
public func <= (lhs: SQLExpressible, rhs: SQLCollatedExpression) -> SQLExpression {
|
||||
.collated(lhs <= rhs.expression, rhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `<=` SQL operator.
|
||||
///
|
||||
/// // width <= height
|
||||
@@ -354,14 +238,6 @@ public func > (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpressio
|
||||
.binary(.greaterThan, lhs.sqlExpression, rhs.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `>` SQL operator.
|
||||
///
|
||||
/// // name > 'Arthur' COLLATE NOCASE
|
||||
/// Column("name").collating(.nocase) > "Arthur"
|
||||
public func > (lhs: SQLCollatedExpression, rhs: SQLExpressible) -> SQLExpression {
|
||||
.collated(lhs.expression > rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `>` SQL operator.
|
||||
///
|
||||
/// // 18 > score
|
||||
@@ -370,14 +246,6 @@ public func > (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpressio
|
||||
.binary(.greaterThan, lhs.sqlExpression, rhs.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `>` SQL operator.
|
||||
///
|
||||
/// // 'Arthur' > name COLLATE NOCASE
|
||||
/// "Arthur" > Column("name").collating(.nocase)
|
||||
public func > (lhs: SQLExpressible, rhs: SQLCollatedExpression) -> SQLExpression {
|
||||
.collated(lhs > rhs.expression, rhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `>` SQL operator.
|
||||
///
|
||||
/// // width > height
|
||||
@@ -394,14 +262,6 @@ public func >= (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpressi
|
||||
.binary(.greaterThanOrEqual, lhs.sqlExpression, rhs.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `>=` SQL operator.
|
||||
///
|
||||
/// // name >= 'Arthur' COLLATE NOCASE
|
||||
/// Column("name").collating(.nocase) >= "Arthur"
|
||||
public func >= (lhs: SQLCollatedExpression, rhs: SQLExpressible) -> SQLExpression {
|
||||
.collated(lhs.expression >= rhs, lhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `>=` SQL operator.
|
||||
///
|
||||
/// // 18 >= score
|
||||
@@ -410,14 +270,6 @@ public func >= (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpressi
|
||||
.binary(.greaterThanOrEqual, lhs.sqlExpression, rhs.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `>=` SQL operator.
|
||||
///
|
||||
/// // 'Arthur' >= name COLLATE NOCASE
|
||||
/// "Arthur" >= Column("name").collating(.nocase)
|
||||
public func >= (lhs: SQLExpressible, rhs: SQLCollatedExpression) -> SQLExpression {
|
||||
.collated(lhs >= rhs.expression, rhs.collationName)
|
||||
}
|
||||
|
||||
/// An SQL expression that compares two expressions with the `>=` SQL operator.
|
||||
///
|
||||
/// // width >= height
|
||||
@@ -436,14 +288,6 @@ extension Range where Bound: SQLExpressible {
|
||||
public func contains(_ element: SQLSpecificExpressible) -> SQLExpression {
|
||||
(element >= lowerBound) && (element < upperBound)
|
||||
}
|
||||
|
||||
/// An SQL expression that checks the inclusion of an expression in a range.
|
||||
///
|
||||
/// // email >= 'A' COLLATE NOCASE AND email < 'B' COLLATE NOCASE
|
||||
/// ("A"..<"B").contains(Column("email").collating(.nocase))
|
||||
public func contains(_ element: SQLCollatedExpression) -> SQLExpression {
|
||||
(element >= lowerBound) && (element < upperBound)
|
||||
}
|
||||
}
|
||||
|
||||
extension ClosedRange where Bound: SQLExpressible {
|
||||
@@ -457,14 +301,6 @@ extension ClosedRange where Bound: SQLExpressible {
|
||||
lowerBound: lowerBound.sqlExpression,
|
||||
upperBound: upperBound.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that checks the inclusion of an expression in a range.
|
||||
///
|
||||
/// // email BETWEEN 'A' AND 'B' COLLATE NOCASE
|
||||
/// ("A"..."B").contains(Column("email").collating(.nocase))
|
||||
public func contains(_ element: SQLCollatedExpression) -> SQLExpression {
|
||||
.collated(contains(element.expression), element.collationName)
|
||||
}
|
||||
}
|
||||
|
||||
extension CountableRange where Bound: SQLExpressible {
|
||||
@@ -499,15 +335,6 @@ extension Sequence where Self.Iterator.Element: SQLExpressible {
|
||||
public func contains(_ element: SQLSpecificExpressible) -> SQLExpression {
|
||||
SQLCollection.array(map(\.sqlExpression)).contains(element.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that checks the inclusion of an expression in
|
||||
/// a sequence.
|
||||
///
|
||||
/// // (name COLLATE NOCASE) IN ('A', 'B')
|
||||
/// ["A", "B"].contains(Column("name").collating(.nocase))
|
||||
public func contains(_ element: SQLCollatedExpression) -> SQLExpression {
|
||||
SQLCollection.array(map(\.sqlExpression)).contains(element.sqlExpression)
|
||||
}
|
||||
}
|
||||
|
||||
extension Sequence where Self.Iterator.Element == SQLExpressible {
|
||||
@@ -519,15 +346,6 @@ extension Sequence where Self.Iterator.Element == SQLExpressible {
|
||||
public func contains(_ element: SQLSpecificExpressible) -> SQLExpression {
|
||||
SQLCollection.array(map(\.sqlExpression)).contains(element.sqlExpression)
|
||||
}
|
||||
|
||||
/// An SQL expression that checks the inclusion of an expression in
|
||||
/// a sequence.
|
||||
///
|
||||
/// // (name COLLATE NOCASE) IN ('A', 'B')
|
||||
/// ["A", "B"].contains(Column("name").collating(.nocase))
|
||||
public func contains(_ element: SQLCollatedExpression) -> SQLExpression {
|
||||
SQLCollection.array(map(\.sqlExpression)).contains(element.sqlExpression)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -114,16 +114,6 @@ extension SQLSubqueryable {
|
||||
SQLCollection.subquery(sqlSubquery).contains(element.sqlExpression)
|
||||
}
|
||||
|
||||
/// Returns an expression that checks the inclusion of the expression in
|
||||
/// the subquery.
|
||||
///
|
||||
/// // name COLLATE NOCASE IN (SELECT name FROM player)
|
||||
/// let request = Player.select(Column("name"), as: String.self)
|
||||
/// let condition = request.contains(Column("name").collating(.nocase))
|
||||
public func contains(_ element: SQLCollatedExpression) -> SQLExpression {
|
||||
SQLCollection.subquery(sqlSubquery).contains(element.sqlExpression)
|
||||
}
|
||||
|
||||
/// Returns an expression that is true if and only if the subquery would
|
||||
/// return one or more rows.
|
||||
///
|
||||
|
||||
@@ -509,8 +509,6 @@
|
||||
56F34FC024B094D2007513FC /* SQLExpressionIsConstantTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F34FBD24B094D1007513FC /* SQLExpressionIsConstantTests.swift */; };
|
||||
56F34FC624B0A0C9007513FC /* SQLIdentifyingColumnsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F34FC524B0A0C8007513FC /* SQLIdentifyingColumnsTests.swift */; };
|
||||
56F34FC724B0A0C9007513FC /* SQLIdentifyingColumnsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F34FC524B0A0C8007513FC /* SQLIdentifyingColumnsTests.swift */; };
|
||||
56F34FF124B0F0D8007513FC /* SQLCollatedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F34FF024B0F0D8007513FC /* SQLCollatedExpression.swift */; };
|
||||
56F34FF224B0F0D8007513FC /* SQLCollatedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F34FF024B0F0D8007513FC /* SQLCollatedExpression.swift */; };
|
||||
56F3E74C1E66F83A00BF0F01 /* ResultCodeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F3E7481E66F83A00BF0F01 /* ResultCodeTests.swift */; };
|
||||
56F3E7501E66F83A00BF0F01 /* ResultCodeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F3E7481E66F83A00BF0F01 /* ResultCodeTests.swift */; };
|
||||
56FBFED62210731100945324 /* SQLRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FBFED52210731000945324 /* SQLRequest.swift */; };
|
||||
@@ -1097,7 +1095,6 @@
|
||||
56F0B98E1B6001C600A2F135 /* FoundationNSDateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationNSDateTests.swift; sourceTree = "<group>"; };
|
||||
56F34FBD24B094D1007513FC /* SQLExpressionIsConstantTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLExpressionIsConstantTests.swift; sourceTree = "<group>"; };
|
||||
56F34FC524B0A0C8007513FC /* SQLIdentifyingColumnsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLIdentifyingColumnsTests.swift; sourceTree = "<group>"; };
|
||||
56F34FF024B0F0D8007513FC /* SQLCollatedExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLCollatedExpression.swift; sourceTree = "<group>"; };
|
||||
56F3E7481E66F83A00BF0F01 /* ResultCodeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResultCodeTests.swift; sourceTree = "<group>"; };
|
||||
56FBFED52210731000945324 /* SQLRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLRequest.swift; sourceTree = "<group>"; };
|
||||
56FDECE11BB32DFD009AD709 /* RowFromStatementTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowFromStatementTests.swift; sourceTree = "<group>"; };
|
||||
@@ -1546,7 +1543,6 @@
|
||||
5656A84A2295BD56001FF3FF /* Column.swift */,
|
||||
5656A8A52295BF44001FF3FF /* DatabasePromise.swift */,
|
||||
5656A8412295BD56001FF3FF /* SQLAssociation.swift */,
|
||||
56F34FF024B0F0D8007513FC /* SQLCollatedExpression.swift */,
|
||||
5656A8432295BD56001FF3FF /* SQLCollection.swift */,
|
||||
5656A8442295BD56001FF3FF /* SQLExpression.swift */,
|
||||
5656A8422295BD56001FF3FF /* SQLForeignKeyRequest.swift */,
|
||||
@@ -2329,7 +2325,6 @@
|
||||
5674A6ED1F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */,
|
||||
568ECB0E25D904CA00B71526 /* SQLSelection.swift in Sources */,
|
||||
5657AB141D10899D006283EF /* URL.swift in Sources */,
|
||||
56F34FF224B0F0D8007513FC /* SQLCollatedExpression.swift in Sources */,
|
||||
56DAA2E01DE9C827006E10C8 /* Cursor.swift in Sources */,
|
||||
F3BA800C1CFB286F003DC1BA /* DatabaseError.swift in Sources */,
|
||||
5656A8782295BD56001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */,
|
||||
@@ -2688,7 +2683,6 @@
|
||||
5674A6EC1F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */,
|
||||
568ECB0D25D904CA00B71526 /* SQLSelection.swift in Sources */,
|
||||
5657AB111D10899D006283EF /* URL.swift in Sources */,
|
||||
56F34FF124B0F0D8007513FC /* SQLCollatedExpression.swift in Sources */,
|
||||
56DAA2DD1DE9C827006E10C8 /* Cursor.swift in Sources */,
|
||||
F3BA80681CFB2E55003DC1BA /* DatabaseError.swift in Sources */,
|
||||
5656A8772295BD56001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */,
|
||||
|
||||
@@ -196,7 +196,7 @@ class QueryInterfaceExpressionsTests: GRDBTestCase {
|
||||
// Sequence.contains(): = operator
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(AnySequence([Col.name]).contains(Col.name.collating(.nocase)))),
|
||||
"SELECT * FROM \"readers\" WHERE (\"name\" COLLATE NOCASE) = \"name\"")
|
||||
"SELECT * FROM \"readers\" WHERE \"name\" = \"name\" COLLATE NOCASE")
|
||||
|
||||
// Sequence.contains(): false
|
||||
XCTAssertEqual(
|
||||
|
||||
@@ -46,12 +46,12 @@ class SQLExpressionIsConstantTests: GRDBTestCase {
|
||||
try XCTAssertEqual((alias[Column("a")] < "foo".databaseValue).column(db, for: alias, acceptsBijection: true), nil)
|
||||
|
||||
// SQLExpressionCollate
|
||||
try XCTAssertEqual(Column("a").collating(.binary).sqlExpression.column(db, for: alias, acceptsBijection: false), nil)
|
||||
try XCTAssertEqual(Column("a").collating(.binary).sqlExpression.column(db, for: alias, acceptsBijection: true), nil)
|
||||
try XCTAssertEqual(alias[Column("a")].collating(.binary).sqlExpression.column(db, for: alias, acceptsBijection: false), "a")
|
||||
try XCTAssertEqual(alias[Column("a")].collating(.binary).sqlExpression.column(db, for: alias, acceptsBijection: true), "a")
|
||||
try XCTAssertEqual((alias[Column("a")] + "foo".databaseValue).collating(.binary).sqlExpression.column(db, for: alias, acceptsBijection: false), nil)
|
||||
try XCTAssertEqual((alias[Column("a")] + "foo".databaseValue).collating(.binary).sqlExpression.column(db, for: alias, acceptsBijection: true), "a")
|
||||
try XCTAssertEqual(Column("a").collating(.binary).column(db, for: alias, acceptsBijection: false), nil)
|
||||
try XCTAssertEqual(Column("a").collating(.binary).column(db, for: alias, acceptsBijection: true), nil)
|
||||
try XCTAssertEqual(alias[Column("a")].collating(.binary).column(db, for: alias, acceptsBijection: false), "a")
|
||||
try XCTAssertEqual(alias[Column("a")].collating(.binary).column(db, for: alias, acceptsBijection: true), "a")
|
||||
try XCTAssertEqual((alias[Column("a")] + "foo".databaseValue).collating(.binary).column(db, for: alias, acceptsBijection: false), nil)
|
||||
try XCTAssertEqual((alias[Column("a")] + "foo".databaseValue).collating(.binary).column(db, for: alias, acceptsBijection: true), "a")
|
||||
|
||||
// SQLExpressionContains
|
||||
try XCTAssertEqual([1, 2, 3].contains(alias[Column("a")]).column(db, for: alias, acceptsBijection: false), nil)
|
||||
@@ -152,7 +152,7 @@ class SQLExpressionIsConstantTests: GRDBTestCase {
|
||||
try XCTAssertEqual((alias[Column("a")] - 1).identifyingColums(db, for: alias), [])
|
||||
|
||||
// SQLExpressionCollate
|
||||
try XCTAssertEqual((alias[Column("a")] == 1).collating(.binary).sqlExpression.identifyingColums(db, for: alias), ["a"])
|
||||
try XCTAssertEqual((alias[Column("a")] == 1).collating(.binary).identifyingColums(db, for: alias), ["a"])
|
||||
|
||||
// SQLExpressionContains
|
||||
try XCTAssertEqual([1, 2, 3].contains(alias[Column("a")]).identifyingColums(db, for: alias), [])
|
||||
@@ -275,8 +275,8 @@ class SQLExpressionIsConstantTests: GRDBTestCase {
|
||||
XCTAssertFalse((1.databaseValue - Column("a")).isConstantInRequest)
|
||||
|
||||
// SQLExpressionCollate
|
||||
XCTAssertTrue("foo".databaseValue.collating(.binary).sqlExpression.isConstantInRequest)
|
||||
XCTAssertFalse(Column("a").collating(.binary).sqlExpression.isConstantInRequest)
|
||||
XCTAssertTrue("foo".databaseValue.collating(.binary).isConstantInRequest)
|
||||
XCTAssertFalse(Column("a").collating(.binary).isConstantInRequest)
|
||||
|
||||
// SQLExpressionContains
|
||||
XCTAssertFalse([1, 2, 3].contains(Column("a")).isConstantInRequest)
|
||||
|
||||
Reference in new issue
Block a user