CommonTableExpression.contains(_:)

This commit is contained in:
Gwendal Roué committed 2020-12-06 19:22:30 +01:00
1 parent 26c7441b49
commit f94cecb329
3 files changed
+38

No files matched your search

@@ -145,6 +145,19 @@ extension CommonTableExpression {
public func all() -> QueryInterfaceRequest<RowDecoder> {
QueryInterfaceRequest(relation: relationForAll)
}
/// An SQL expression that checks the inclusion of an expression in a
/// common table expression.
///
/// let playerNameCTE = CommonTableExpression<Void>(
/// named: "playerName",
/// request: Player.select(Column("name"))
///
/// // name IN playerName
/// playerNameCTE.contains(Column("name"))
public func contains(_ element: SQLExpressible) -> SQLExpression {
SQLLiteral("\(element.sqlExpression) IN \(sql: tableName.quotedDatabaseIdentifier)").sqlExpression
}
}
/// A low-level common table expression