Test for SQLCollection qualification

This commit is contained in:
Gwendal Roué committed 2020-04-30 19:01:14 +02:00
1 parent dfcc6f99a5
commit df2cc0af36
2 files changed
+32

No files matched your search

@@ -552,6 +552,26 @@ extension Sequence where Self.Iterator.Element: SQLExpressible {
}
}
extension Sequence where Self.Iterator.Element == SQLExpressible {
/// An SQL expression that checks the inclusion of an expression in
/// a sequence.
///
/// // id IN (1,2,3)
/// [1, 2, 3].contains(Column("id"))
public func contains(_ element: SQLSpecificExpressible) -> SQLExpression {
SQLExpressionsArray(expressions: map(\.sqlExpression)).contains(element.sqlExpression)
}
/// An SQL expression that checks the inclusion of an expression in
/// a sequence.
///
/// // name IN ('A', 'B') COLLATE NOCASE
/// ["A", "B"].contains(Column("name").collating(.nocase))
public func contains(_ element: SQLCollatedExpression) -> SQLExpression {
SQLExpressionCollate(contains(element.expression), collationName: element.collationName)
}
}
// MARK: - Arithmetic Operators (+, -, *, /)