Support for the TOTAL SQL aggregate function

This commit is contained in:
Gwendal Roué committed 2021-12-12 14:46:43 +01:00
1 parent 8ba89a398a
commit ae609cec3b
7 files changed
+149 -2

No files matched your search

@@ -101,6 +101,10 @@ public func min(_ value: SQLSpecificExpressible) -> SQLExpression {
/// Returns an expression that evaluates the `SUM` SQL function.
///
/// See <https://www.sqlite.org/lang_aggfunc.html#sumunc>.
///
/// See also `total(_:)`.
///
/// // SUM(amount)
/// sum(Column("amount"))
public func sum(_ value: SQLSpecificExpressible) -> SQLExpression {
@@ -108,6 +112,21 @@ public func sum(_ value: SQLSpecificExpressible) -> SQLExpression {
}
// MARK: - TOTAL(...)
/// Returns an expression that evaluates the `TOTAL` SQL function.
///
/// See <https://www.sqlite.org/lang_aggfunc.html#sumunc>.
///
/// See also `sum(_:)`.
///
/// // TOTAL(amount)
/// total(Column("amount"))
public func total(_ value: SQLSpecificExpressible) -> SQLExpression {
.aggregate("TOTAL", [value.sqlExpression])
}
// MARK: - String functions
/// :nodoc: