mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
Let hasMany.first include nested associations
This commit is contained in:
1 parent
d67814ef61
commit
d80922954a
3 files changed
+180
-15
No files matched your search
@@ -494,10 +494,16 @@ private struct SQLQualifiedRelation {
|
||||
}
|
||||
|
||||
if child.firstOnly {
|
||||
let relation = child.relation
|
||||
// Filters and order are handled in a subquery
|
||||
.unfiltered()
|
||||
.unordered()
|
||||
// Only keep children with a non-empty selection
|
||||
.filteringChildren { $0.relation.selection.isEmpty == false }
|
||||
return SQLQualifiedJoin(
|
||||
kind: kind,
|
||||
condition: child.condition,
|
||||
relation: SQLQualifiedRelation(child.relation.witnessRelation),
|
||||
relation: SQLQualifiedRelation(relation),
|
||||
target: .firstOnly(child.relation))
|
||||
} else {
|
||||
return SQLQualifiedJoin(
|
||||
@@ -682,7 +688,7 @@ private struct SQLQualifiedJoin: Refinable {
|
||||
|
||||
let rightAlias = relation.sourceAlias
|
||||
switch target {
|
||||
case let .all:
|
||||
case .all:
|
||||
let filters = try condition.expressions(db, leftAlias: leftAlias, rightAlias: rightAlias)
|
||||
+ relation.filtersPromise.resolve(db)
|
||||
if filters.isEmpty == false {
|
||||
|
||||
Reference in new issue
Block a user