Rename AssociationImpl to SQLAssociation

This commit is contained in:
Gwendal Roué committed 2019-03-02 14:46:12 +01:00
1 parent b506838519
commit 08451dfced
5 files changed
+136 -96

No files matched your search

@@ -5,28 +5,44 @@ extension QueryInterfaceRequest where RowDecoder: TableRecord {
/// associated record are selected. The returned association does not
/// require that the associated database table contains a matching row.
public func including<A: Association>(optional association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder {
return mapQuery { $0.mapRelation { association._impl.joinedRelation($0, joinOperator: .optional) } }
return mapQuery {
$0.mapRelation {
association.sqlAssociation.joinedRelation($0, joinOperator: .optional)
}
}
}
/// Creates a request that includes an association. The columns of the
/// associated record are selected. The returned association requires
/// that the associated database table contains a matching row.
public func including<A: Association>(required association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder {
return mapQuery { $0.mapRelation { association._impl.joinedRelation($0, joinOperator: .required) } }
return mapQuery {
$0.mapRelation {
association.sqlAssociation.joinedRelation($0, joinOperator: .required)
}
}
}
/// Creates a request that includes an association. The columns of the
/// associated record are not selected. The returned association does not
/// require that the associated database table contains a matching row.
public func joining<A: Association>(optional association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder {
return mapQuery { $0.mapRelation { association.select([])._impl.joinedRelation($0, joinOperator: .optional) } }
return mapQuery {
$0.mapRelation {
association.select([]).sqlAssociation.joinedRelation($0, joinOperator: .optional)
}
}
}
/// Creates a request that includes an association. The columns of the
/// associated record are not selected. The returned association requires
/// that the associated database table contains a matching row.
public func joining<A: Association>(required association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder {
return mapQuery { $0.mapRelation { association.select([])._impl.joinedRelation($0, joinOperator: .required) } }
return mapQuery {
$0.mapRelation {
association.select([]).sqlAssociation.joinedRelation($0, joinOperator: .required)
}
}
}
// MARK: - Association Aggregates
@@ -91,7 +107,7 @@ extension MutablePersistableRecord {
/// let team: Team = ...
/// let players = try team.players.fetchAll(db) // [Player]
public func request<A: Association>(for association: A) -> QueryInterfaceRequest<A.RowDecoder> where A.OriginRowDecoder == Self {
return association.request(from: self)
return association.sqlAssociation.request(of: A.RowDecoder.self, from: self)
}
}