Skip to content

Structure

SQLDistinct

An expression representing the subexpression of an aggregate function call which specifies whether the aggregate groups over all result rows or only distinct rows.
struct SQLDistinct

Overview

This expression is another example of incomplete API design; it should properly be implemented as an expression called SQLAggregateFunction which includes the aggregate function name as part of the expression and allows specifying ORDER BY and FILTER clauses as supported by various dialects. An example of using it in the current implementation:

let count = try await database.select()
    .column(SQLFunction("count", SQLDistinct(SQLColumn("column1"))), as: "count")
    .first(decodingColumn: "count", as: Int.self)!

Topics

Initializers

  • init(_:)
    Create a DISTINCT expression with a list of string identifiers.

Instance Properties

Instance Methods

Type Properties

Relationships

Conforms To

See Also

Basic Expressions

  • struct SQLAlias
    Encapsulates SQL’s <expression> [AS] <name> syntax, most often used to declare aliaed names for columns and tables.
  • struct SQLBetween
    An SQLExpression which constructs SQL of the form <operand> BETWEEN <lowerBound> AND <upperBound>.
  • struct SQLColumn
    An expression representing an optionally table-qualified column in an SQL table.
  • struct SQLConstraint
    An expression representing the combination of a constraint name and algorithm for table constraints.
  • enum SQLDataType
    Represents a value’s type in SQL.
  • enum SQLDirection
    Describes an ordering direction for a given sorting key.
  • enum SQLForeignKeyAction
    An expression specifying a behavior for a foreign key constraint violation.
  • struct SQLNestedSubpathExpression
    A “nested subpath” expression is used to descend into the “deeper” structure of a non-scalar value, such as a dictionary, array, or JSON value.
  • struct SQLQualifiedTable
    An expression representing an optionally second-level-qualified SQL table.
  • struct SQLQueryString
    An expression consisting of an array of constituent subexpressions generated by custom string interpolations.