Skip to content

Commit 9107dbc

Browse files
committed
wip
1 parent 53dd31b commit 9107dbc

35 files changed

+8472
-8167
lines changed

Sources/StructuredQueriesCore/Never.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
extension Never: Table {
2+
public typealias QueryValue = Never
3+
24
public struct TableColumns: TableDefinition {
35
public typealias QueryValue = Never
46

@@ -11,6 +13,10 @@ extension Never: Table {
1113

1214
public static let tableName = "nevers"
1315

16+
public var queryFragment: QueryFragment {
17+
fatalError()
18+
}
19+
1420
public init(decoder: inout some QueryDecoder) throws {
1521
throw NotDecodable()
1622
}

Sources/StructuredQueriesCore/Operators.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extension QueryExpression where QueryValue: QueryBindable {
1+
extension QueryExpression where QueryValue: _OptionalPromotable {
22
/// A predicate expression indicating whether two query expressions are equal.
33
///
44
/// ```swift
@@ -963,7 +963,7 @@ struct BinaryOperator<QueryValue>: QueryExpression {
963963
}
964964

965965
var queryFragment: QueryFragment {
966-
"(\(lhs) \(`operator`) \(rhs))"
966+
"(\(lhs)) \(`operator`) (\(rhs))"
967967
}
968968
}
969969

Sources/StructuredQueriesCore/QueryRepresentable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Foundation
1212
/// offsets from the Unix epoch, or double Julian day numbers. This library defaults to ISO-8601
1313
/// text, but provides ``Foundation/Date/UnixTimeRepresentation`` to represent a date as an integer,
1414
/// and ``Foundation/Date/JulianDayRepresentation`` to represent a date as a floating point number.
15-
public protocol QueryRepresentable<QueryOutput>: QueryDecodable {
15+
public protocol QueryRepresentable<QueryOutput>: QueryDecodable, QueryExpression {
1616
/// The Swift type this value is ultimately decoded to.
1717
associatedtype QueryOutput
1818

Sources/StructuredQueriesCore/Updates.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public struct Updates<Base: Table> {
99
private var updates: [(String, QueryFragment)] = []
1010

11-
init(_ body: (inout Self) -> Void) {
11+
package init(_ body: (inout Self) -> Void) {
1212
body(&self)
1313
}
1414

@@ -59,3 +59,12 @@ extension Updates: QueryExpression {
5959
"SET \(updates.map { "\(quote: $0) = \($1)" }.joined(separator: ", "))"
6060
}
6161
}
62+
63+
extension Updates {
64+
public subscript<Member: TableDefinition>(
65+
dynamicMember keyPath: KeyPath<Base.TableColumns, Member>
66+
) -> Updates<Member.QueryValue> {
67+
get { Updates<Member.QueryValue> { _ in } }
68+
set { updates.append(contentsOf: newValue.updates) }
69+
}
70+
}

0 commit comments

Comments
 (0)