JoinAssociation
The JoinAssociation
joins common table expression to regular tables or other common table expressions.
struct JoinAssociation<Origin, Destination>
The JoinAssociation
joins common table expression to regular tables or other common table expressions.
struct JoinAssociation<Origin, Destination>
import GRDB
A toolkit for SQLite databases, with a focus on application development
var _sqlAssociation: _SQLAssociation
typealias OriginRowDecoder = Origin
typealias RowDecoder = Destination
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol Escapable
protocol AggregatingRequest
A request that can aggregate database rows.
protocol Association : DerivableRequest, Sendable
A type that defines a connection between two tables.
protocol AssociationToOne : Association
An association that defines a to-one connection.
protocol DerivableRequest<RowDecoder> : AggregatingRequest, FilteredRequest, JoinableRequest, OrderedRequest, SelectionRequest, TableRequest
DerivableRequest
is the base protocol for QueryInterfaceRequest
and Association
.
protocol FilteredRequest
A request that can filter database rows.
protocol JoinableRequest<RowDecoder> : TypedRequest
A request that can join and prefetch associations.
protocol OrderedRequest
A request that can sort database rows.
protocol SelectionRequest
A request that can define the selected columns.
protocol Sendable
protocol TableRequest
A request that feeds from a database table
protocol TypedRequest<RowDecoder>
A request that knows how to decode database rows.
var databaseTableName: String { get }
func _including(all association: _SQLAssociation) -> Self
func _including(optional association: _SQLAssociation) -> Self
func _including(required association: _SQLAssociation) -> Self
func _joining(optional association: _SQLAssociation) -> Self
func _joining(required association: _SQLAssociation) -> Self
func aliased(_ alias: TableAlias) -> Self
func all() -> Self
Returns self
: a request that fetches all rows from this request.
func annotated(with aggregates: [AssociationAggregate<RowDecoder>]) -> Self
Appends association aggregates to the selected columns.
func annotated<A>(withOptional association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
Appends the columns of the eventual associated record to the selected columns.
func annotated<A>(withRequired association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
Appends the columns of the associated record to the selected columns. Records that do not have an associated record are discarded.
func annotatedWhenConnected(with selection: @escaping (Database) throws -> [any SQLSelectable]) -> Self
func distinct() -> Self
func filter(_ predicate: some SQLSpecificExpressible) -> Self
Filters the fetched rows with a boolean SQL expression.
func filter(key: [String : (any DatabaseValueConvertible)?]?) -> Self
Filters by primary or unique key.
func filter(keys: [[String : (any DatabaseValueConvertible)?]]) -> Self
Filters by primary or unique key.
func filter(literal sqlLiteral: SQL) -> Self
Filters the fetched rows with an SQL
literal.
func filter(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
Filters the fetched rows with an SQL string.
func filterWhenConnected(_ predicate: @escaping (Database) throws -> any SQLExpressible) -> Self
func forKey(_ key: String) -> Self
func group(_ expressions: [any SQLExpressible]) -> Self
Returns an aggregate request grouped on the given SQL expressions.
func group(literal sqlLiteral: SQL) -> Self
Returns an aggregate request grouped on an SQL
literal.
func group(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
Returns an aggregate request grouped on an SQL string.
func groupByPrimaryKey() -> Self
Returns an aggregate request grouped on the primary key.
func groupWhenConnected(_ expressions: @escaping (Database) throws -> [any SQLExpressible]) -> Self
func having(_ predicate: AssociationAggregate<RowDecoder>) -> Self
Filters the fetched records with an association aggregate.
func having(literal sqlLiteral: SQL) -> Self
Filters the aggregated groups with an SQL
literal.
func having(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
Filters the aggregated groups with an SQL string.
func havingWhenConnected(_ predicate: @escaping (Database) throws -> any SQLExpressible) -> Self
func including<A>(all association: A) -> Self where A : AssociationToMany, Self.RowDecoder == A.OriginRowDecoder
Returns a request that fetches all records associated with each record in this request.
func including<A>(optional association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
Returns a request that fetches the eventual record associated with each record of this request.
func including<A>(required association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
Returns a request that fetches the record associated with each record in this request. Records that do not have an associated record are discarded.
func joining<A>(optional association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
Returns a request that joins each record of this request to its eventual associated record.
func joining<A>(required association: A) -> Self where A : Association, Self.RowDecoder == A.OriginRowDecoder
Returns a request that joins each record of this request to its associated record. Records that do not have an associated record are discarded.
func matching(_ pattern: FTS3Pattern?) -> Self
Filters rows that match an FTS3
full-text pattern.
func matching(_ pattern: FTS5Pattern?) -> Self
Filters rows that match an FTS5
full-text pattern.
func none() -> Self
Returns an empty request that fetches no row.
func order(_ orderings: [any SQLOrderingTerm]) -> Self
Sorts the fetched rows according to the given SQL ordering terms.
func order(literal sqlLiteral: SQL) -> Self
Sorts the fetched rows according to the given SQL
literal.
func order(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
Sorts the fetched rows according to the given SQL string.
func orderByPrimaryKey() -> Self
Sorts the fetched rows according to the primary key.
func orderWhenConnected(_ orderings: @escaping (Database) throws -> [any SQLOrderingTerm]) -> Self
func reversed() -> Self
func select(_ selection: [any SQLSelectable]) -> Self
Defines the result columns.
func select(literal sqlLiteral: SQL) -> Self
Defines the result columns with an SQL
literal.
func select(sql: String, arguments: StatementArguments = StatementArguments()) -> Self
Defines the result columns with an SQL string.
func selectWhenConnected(_ selection: @escaping (Database) throws -> [any SQLSelectable]) -> Self
func unordered() -> Self
func withStableOrder() -> Self