mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
Cleanup
This commit is contained in:
1 parent
3786482368
commit
604a51bb79
1 file changed
+10
-6
@@ -70,7 +70,7 @@ extension Association {
|
||||
/// let team: Team = row["custom"]
|
||||
/// }
|
||||
var key: String {
|
||||
return sqlAssociation.key
|
||||
return sqlAssociation.destinationKey
|
||||
}
|
||||
|
||||
/// Creates an association which selects *selection*.
|
||||
@@ -510,17 +510,21 @@ public /* TODO: internal */ struct SQLAssociation {
|
||||
return AssociationStep(key: key, condition: condition, relation: transform(relation))
|
||||
}
|
||||
}
|
||||
private var steps: [AssociationStep] // Never empty. Last is destination.
|
||||
|
||||
// All steps, from pivot to destination. Never empty.
|
||||
private var steps: [AssociationStep]
|
||||
var keyPath: [String] { return steps.map { $0.key} }
|
||||
|
||||
private var destination: AssociationStep {
|
||||
get { return steps[steps.count - 1] }
|
||||
set { steps[steps.count - 1] = newValue }
|
||||
}
|
||||
var destinationKey: String { return destination.key }
|
||||
|
||||
private var pivot: AssociationStep {
|
||||
get { return steps[0] }
|
||||
set { steps[0] = newValue }
|
||||
}
|
||||
var key: String { return destination.key }
|
||||
var keyPath: [String] { return steps.map { $0.key} }
|
||||
var pivotCondition: SQLAssociationCondition {
|
||||
return pivot.condition
|
||||
}
|
||||
@@ -547,7 +551,7 @@ public /* TODO: internal */ struct SQLAssociation {
|
||||
result.pivot.key = key
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
/// Transforms the destination relation
|
||||
func mapDestinationRelation(_ transform: (SQLRelation) -> SQLRelation) -> SQLAssociation {
|
||||
var result = self
|
||||
@@ -561,7 +565,7 @@ public /* TODO: internal */ struct SQLAssociation {
|
||||
result.pivot = result.pivot.mapRelation(transform)
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
/// Returns a new association
|
||||
func through(_ other: SQLAssociation) -> SQLAssociation {
|
||||
return SQLAssociation(steps: other.steps + steps)
|
||||
|
||||
Reference in new issue
Block a user