mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-22 04:00:39 +00:00
# Conflicts: # GRDB/QueryInterface/Request/Association/Association.swift # GRDB/QueryInterface/Request/QueryInterfaceRequest.swift # GRDB/QueryInterface/SQL/SQLQuery.swift # GRDB/QueryInterface/SQLGeneration/SQLGenerationContext.swift # GRDB/QueryInterface/SQLGeneration/SQLQueryGenerator.swift
30 lines
902 B
Swift
30 lines
902 B
Swift
/// The Join association is used to join common table expression to regular
|
|
/// tables or other common table expressions.
|
|
public struct JoinAssociation<Origin, Destination>: AssociationToOne {
|
|
/// :nodoc:
|
|
public typealias OriginRowDecoder = Origin
|
|
|
|
/// :nodoc:
|
|
public typealias RowDecoder = Destination
|
|
|
|
/// :nodoc:
|
|
public var _sqlAssociation: _SQLAssociation
|
|
|
|
/// :nodoc:
|
|
public init(sqlAssociation: _SQLAssociation) {
|
|
self._sqlAssociation = sqlAssociation
|
|
}
|
|
|
|
/// Creates a `JoinAssociation` whose key is the table name of the relation.
|
|
init(
|
|
to relation: SQLRelation,
|
|
condition: SQLAssociationCondition)
|
|
{
|
|
_sqlAssociation = _SQLAssociation(
|
|
key: .inflected(relation.source.tableName),
|
|
condition: condition,
|
|
relation: relation,
|
|
cardinality: .toOne)
|
|
}
|
|
}
|