File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Sources/StructuredQueriesCore/Statements
Tests/StructuredQueriesTests Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -444,6 +444,18 @@ extension Select {
444444 _select ( selection)
445445 }
446446
447+ /// Creates a new select statement from this one by selecting the given result column.
448+ ///
449+ /// - Parameter selection: A closure that selects a result column from this select's tables.
450+ /// - Returns: A new select statement that selects the given column.
451+ @_disfavoredOverload
452+ public func select< C: QueryExpression , each J : Table > (
453+ _ selection: ( From . TableColumns , repeat ( each J ) . TableColumns) -> C
454+ ) -> Select < C . QueryValue , From , ( repeat each J ) >
455+ where Columns == ( ) , C. QueryValue: QueryRepresentable , Joins == ( repeat each J ) {
456+ _select ( selection)
457+ }
458+
447459 /// Creates a new select statement from this one by appending the given result column to its
448460 /// selection.
449461 ///
Original file line number Diff line number Diff line change 1+ import StructuredQueries
2+
3+ // NB: This is a compile-time test for a 'select' overload.
4+ @Selection
5+ private struct ReminderRow {
6+ let reminder : Reminder
7+ let isPastDue : Bool
8+ @Column ( as: [ String ] . JSONRepresentation. self)
9+ let tags : [ String ]
10+ }
11+ private var remindersQuery : some Statement < ReminderRow > {
12+ Reminder
13+ . limit ( 1 )
14+ . select {
15+ ReminderRow . Columns (
16+ reminder: $0,
17+ isPastDue: true ,
18+ tags: #sql( " [] " )
19+ )
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments