SQLAssociation.associationForFirst()

This commit is contained in:
Gwendal Roué committed 2020-04-18 16:40:22 +02:00
1 parent 4483f037a4
commit 6f125bd3d7
2 files changed
+6 -4

No files matched your search

@@ -97,6 +97,10 @@ public /* TODO: internal */ struct SQLAssociation {
SQLAssociation(steps: other.steps + steps)
}
func associationForFirst() -> Self {
SQLAssociation(steps: steps.map { $0.with(\.firstOnly, true) })
}
/// Given an origin alias and rows, returns the destination of the
/// association as a relation.
///
@@ -204,6 +208,7 @@ struct SQLAssociationStep: Refinable {
var key: SQLAssociationKey
var condition: SQLAssociationCondition
var relation: SQLRelation
// TODO: I have problems understanding what cardinality=toMany + firstOnly=true mean.
var cardinality: SQLAssociationCardinality
var firstOnly: Bool