Back to basics, round 2: keep all children of firstOnly relations

This commit is contained in:
Gwendal Roué committed 2020-04-19 17:44:50 +02:00
1 parent a7b8a73dba
commit df4d5b8603
3 files changed
+423 -190

No files matched your search

@@ -656,11 +656,6 @@ private struct SQLQualifiedJoin: Refinable {
// Outer relation has no filter or ordering: those are handled
// by the subRelation.
guard relation.children.isEmpty else {
// TODO: handle children
fatalError("Not implemented: associating records to a `first` or `last` to-one association")
}
let outerRelation = relation
.with(\.firstOnly, false)
.unfiltered()
@@ -728,7 +723,7 @@ private struct SQLQualifiedJoin: Refinable {
guard let primaryKey = try subRelation.primaryKeyExpression(db) else {
fatalError("Not implemented: support for WITHOUT ROWID optimization")
}
subRelation = subRelation.select([primaryKey])
subRelation = subRelation.selectOnly([primaryKey])
// Subquery: ... WHERE <condition filters> AND <other filters>
let filters = try condition.expressions(db, leftAlias: leftAlias)