Merge associations: including wins over joining

This commit is contained in:
Gwendal Roué committed 2018-09-29 14:37:53 +02:00
1 parent 33b40637a8
commit 37a9999b35
2 files changed
+147 -1

No files matched your search

@@ -178,9 +178,17 @@ extension AssociationQuery {
mergedJoins.append(value: join, forKey: key)
}
// There is a possible conflict when both selections are not empty.
let mergedSelection: [SQLSelectable]
if selection.isEmpty {
mergedSelection = other.selection
} else {
mergedSelection = selection
}
return AssociationQuery(
source: mergedSource,
selection: other.selection, // possible conflict with self.selection here.
selection: mergedSelection,
filterPromise: mergedFilterPromise,
ordering: other.ordering, // reorder
joins: mergedJoins)