mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Rename ToOneAssociation to AssociationToOne
This commit is contained in:
1 parent
4d5e5e1de3
commit
9ee25fdec1
5 files changed
+13
-24
No files matched your search
@@ -283,12 +283,12 @@ extension Association where Self: TableRequest, RowDecoder: TableRecord {
|
||||
public var databaseTableName: String { return RowDecoder.databaseTableName }
|
||||
}
|
||||
|
||||
// MARK: - ToOneAssociation
|
||||
// MARK: - AssociationToOne
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
///
|
||||
/// The base protocol for all associations that define a one-to-one connection.
|
||||
public protocol ToOneAssociation: Association { }
|
||||
public protocol AssociationToOne: Association { }
|
||||
|
||||
// MARK: - SQLAssociation
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
/// }
|
||||
///
|
||||
/// See ForeignKey for more information.
|
||||
public struct BelongsToAssociation<Origin, Destination>: ToOneAssociation {
|
||||
public struct BelongsToAssociation<Origin, Destination>: AssociationToOne {
|
||||
/// :nodoc:
|
||||
public typealias OriginRowDecoder = Origin
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
/// }
|
||||
///
|
||||
/// See ForeignKey for more information.
|
||||
public struct HasOneAssociation<Origin, Destination>: ToOneAssociation {
|
||||
public struct HasOneAssociation<Origin, Destination>: AssociationToOne {
|
||||
/// :nodoc:
|
||||
public typealias OriginRowDecoder = Origin
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
public struct HasOneThroughAssociation<Origin, Destination>: ToOneAssociation {
|
||||
public struct HasOneThroughAssociation<Origin, Destination>: AssociationToOne {
|
||||
/// :nodoc:
|
||||
public typealias OriginRowDecoder = Origin
|
||||
|
||||
@@ -22,22 +22,11 @@ extension TableRecord {
|
||||
_ target: Target,
|
||||
through pivot: Pivot)
|
||||
-> HasOneThroughAssociation<Self, Target.RowDecoder>
|
||||
where Pivot: ToOneAssociation,
|
||||
Target: ToOneAssociation,
|
||||
where Pivot: AssociationToOne,
|
||||
Target: AssociationToOne,
|
||||
Pivot.OriginRowDecoder == Self,
|
||||
Pivot.RowDecoder == Target.OriginRowDecoder
|
||||
{
|
||||
return HasOneThroughAssociation(sqlAssociation: target.sqlAssociation.appending(pivot.sqlAssociation))
|
||||
}
|
||||
}
|
||||
|
||||
extension ToOneAssociation {
|
||||
// TODO: look for a replacement for hasOne(_:through:)
|
||||
// hop, chain, jump, hasOne, ... what?
|
||||
public func chaining<Target>(_ target: Target)
|
||||
-> HasOneThroughAssociation<OriginRowDecoder, Target.RowDecoder>
|
||||
where Target: ToOneAssociation, Target.OriginRowDecoder == RowDecoder
|
||||
{
|
||||
return HasOneThroughAssociation(sqlAssociation: target.sqlAssociation.appending(sqlAssociation))
|
||||
}
|
||||
}
|
||||
@@ -177,8 +177,8 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase {
|
||||
ac: CAssociation,
|
||||
bCondition: String,
|
||||
cCondition: String) throws
|
||||
where BAssociation: ToOneAssociation,
|
||||
CAssociation: ToOneAssociation,
|
||||
where BAssociation: AssociationToOne,
|
||||
CAssociation: AssociationToOne,
|
||||
BAssociation.OriginRowDecoder == CAssociation.OriginRowDecoder,
|
||||
BAssociation.OriginRowDecoder: TableRecord
|
||||
{
|
||||
@@ -782,10 +782,10 @@ class AssociationHasOneThroughSQLTests: GRDBTestCase {
|
||||
bCondition: String,
|
||||
cCondition: String,
|
||||
dCondition: String) throws
|
||||
where BAssociation: ToOneAssociation,
|
||||
CAssociation: ToOneAssociation,
|
||||
DCAssociation: ToOneAssociation,
|
||||
DBAssociation: ToOneAssociation,
|
||||
where BAssociation: AssociationToOne,
|
||||
CAssociation: AssociationToOne,
|
||||
DCAssociation: AssociationToOne,
|
||||
DBAssociation: AssociationToOne,
|
||||
BAssociation.OriginRowDecoder == CAssociation.OriginRowDecoder,
|
||||
BAssociation.OriginRowDecoder == DCAssociation.OriginRowDecoder,
|
||||
BAssociation.OriginRowDecoder == DBAssociation.OriginRowDecoder,
|
||||
|
||||
Reference in new issue
Block a user