Skip to content

Commit 0d8de76

Browse files
committed
wip
1 parent 86a3739 commit 0d8de76

File tree

2 files changed

+43
-44
lines changed

2 files changed

+43
-44
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
@dynamicMemberLookup
2+
public struct SubtableColumns<Root: Table, Value: Table>: QueryExpression {
3+
public typealias QueryValue = Value
4+
5+
public static func allColumns(keyPath: KeyPath<Root, Value> & Sendable) -> [any TableColumnExpression] {
6+
return Value.TableColumns.allColumns.map { column in
7+
func open<R, V>(
8+
_ column: some TableColumnExpression<R, V>
9+
) -> any TableColumnExpression {
10+
let keyPath = keyPath.appending(
11+
path: unsafeDowncast(column.keyPath, to: KeyPath<Value, V.QueryOutput>.self)
12+
)
13+
return TableColumn<Root, V>(
14+
column.name,
15+
keyPath: keyPath.unsafeSendable(),
16+
default: column.defaultValue
17+
)
18+
}
19+
return open(column)
20+
}
21+
}
22+
23+
let keyPath: KeyPath<Root, Value> & Sendable
24+
25+
public init(keyPath: KeyPath<Root, Value> & Sendable) {
26+
self.keyPath = keyPath
27+
}
28+
29+
public subscript<Member>(
30+
dynamicMember keyPath: KeyPath<Value.TableColumns, TableColumn<Value, Member>> & Sendable
31+
) -> TableColumn<Root, Member> {
32+
let column = Value.columns[keyPath: keyPath]
33+
return TableColumn<Root, Member>(
34+
column.name,
35+
keyPath: self.keyPath.appending(path: column._keyPath).unsafeSendable(),
36+
default: column.defaultValue
37+
)
38+
}
39+
40+
public var queryFragment: QueryFragment {
41+
Value.columns.queryFragment
42+
}
43+
}

Sources/StructuredQueriesCore/Updates.swift

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -68,47 +68,3 @@ extension Updates {
6868
set { updates.append(contentsOf: newValue.updates) }
6969
}
7070
}
71-
72-
@dynamicMemberLookup
73-
public struct SubtableColumns<Root: Table, Value: Table>: QueryExpression {
74-
public typealias QueryValue = Value
75-
76-
public static func allColumns(keyPath: KeyPath<Root, Value> & Sendable) -> [any TableColumnExpression] {
77-
return Value.TableColumns.allColumns.map { column in
78-
func open<R, V>(
79-
_ column: some TableColumnExpression<R, V>
80-
) -> any TableColumnExpression {
81-
let keyPath = keyPath.appending(
82-
path: unsafeDowncast(column.keyPath, to: KeyPath<Value, V.QueryOutput>.self)
83-
)
84-
return TableColumn<Root, V>(
85-
column.name,
86-
keyPath: keyPath.unsafeSendable(),
87-
default: column.defaultValue
88-
)
89-
}
90-
return open(column)
91-
}
92-
}
93-
94-
let keyPath: KeyPath<Root, Value> & Sendable
95-
96-
public init(keyPath: KeyPath<Root, Value> & Sendable) {
97-
self.keyPath = keyPath
98-
}
99-
100-
public subscript<Member>(
101-
dynamicMember keyPath: KeyPath<Value.TableColumns, TableColumn<Value, Member>> & Sendable
102-
) -> TableColumn<Root, Member> {
103-
let column = Value.columns[keyPath: keyPath]
104-
return TableColumn<Root, Member>(
105-
column.name,
106-
keyPath: self.keyPath.appending(path: column._keyPath).unsafeSendable(),
107-
default: column.defaultValue
108-
)
109-
}
110-
111-
public var queryFragment: QueryFragment {
112-
Value.columns.queryFragment
113-
}
114-
}

0 commit comments

Comments
 (0)