Skip to content

Commit 9f35bc0

Browse files
authored
Disfavor ambiguous DML overload for optional tables (#150)
1 parent bc6f0df commit 9f35bc0

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Sources/StructuredQueriesCore/Optional.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ extension Optional: Table where Wrapped: Table {
114114
Member?.some(Wrapped.columns[keyPath: keyPath])
115115
}
116116

117+
@_disfavoredOverload
117118
public subscript<QueryValue>(
118119
dynamicMember keyPath: KeyPath<Wrapped.TableColumns, some QueryExpression<QueryValue?>>
119120
) -> some QueryExpression<QueryValue?> {

Tests/StructuredQueriesTests/CompileTimeTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,21 @@ private var remindersQuery: some Statement<ReminderRow> {
1919
)
2020
}
2121
}
22+
23+
@Table
24+
private struct Foo {
25+
var id: Int
26+
var barId: Int?
27+
}
28+
@Table
29+
private struct Bar {
30+
var id: Int
31+
var baz: String?
32+
}
33+
func dynamicMemberLookup() {
34+
_ = Foo.all
35+
.leftJoin(Bar.all) { $0.barId.eq($1.id) }
36+
.where { f, b in
37+
b.baz.is(nil)
38+
}
39+
}

0 commit comments

Comments
 (0)