Skip to content

Commit 27bb8da

Browse files
committed
wip
1 parent b8ec7c5 commit 27bb8da

File tree

7 files changed

+21
-17
lines changed

7 files changed

+21
-17
lines changed

Sources/StructuredQueriesCore/Statements/CommonTableExpression.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// Creates a common table expression that can be used to factor subqueries, or create hierarchical
22
/// or recursive queries of trees and graphs.
3-
public struct With<QueryValue>: Statement {
3+
public struct With<QueryValue>: Statement, Sendable {
44
public typealias From = Never
55

66
var ctes: [CommonTableExpressionClause]

Sources/StructuredQueriesCore/Statements/CompoundSelect.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extension PartialSelectStatement {
1111
public func union(
1212
all: Bool = false,
1313
_ other: some PartialSelectStatement<QueryValue>
14-
) -> some PartialSelectStatement<QueryValue> {
14+
) -> some PartialSelectStatement<QueryValue> & Sendable {
1515
CompoundSelect(lhs: self, operator: all ? .unionAll : .union, rhs: other)
1616
}
1717

@@ -25,7 +25,7 @@ extension PartialSelectStatement {
2525
/// - Returns: A compound select statement.
2626
public func intersect<F, J>(
2727
_ other: some SelectStatement<QueryValue, F, J>
28-
) -> some PartialSelectStatement<QueryValue> {
28+
) -> some PartialSelectStatement<QueryValue> & Sendable {
2929
CompoundSelect(lhs: self, operator: .intersect, rhs: other)
3030
}
3131

@@ -38,12 +38,12 @@ extension PartialSelectStatement {
3838
/// - Returns: A compound select statement.
3939
public func except<F, J>(
4040
_ other: some SelectStatement<QueryValue, F, J>
41-
) -> some PartialSelectStatement<QueryValue> {
41+
) -> some PartialSelectStatement<QueryValue> & Sendable {
4242
CompoundSelect(lhs: self, operator: .except, rhs: other)
4343
}
4444
}
4545

46-
private struct CompoundSelect<QueryValue>: PartialSelectStatement {
46+
private struct CompoundSelect<QueryValue>: PartialSelectStatement, Sendable {
4747
typealias From = Never
4848
typealias Joins = Never
4949

Sources/StructuredQueriesCore/Statements/Delete.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extension PrimaryKeyedTable {
3535
/// This type of statement is constructed from ``Table/delete()`` and ``Where/delete()``.
3636
///
3737
/// To learn more, see <doc:DeleteStatements>.
38-
public struct Delete<From: Table, Returning> {
38+
public struct Delete<From: Table, Returning>: Sendable {
3939
var `where`: [QueryFragment] = []
4040
var returning: [QueryFragment] = []
4141

Sources/StructuredQueriesCore/Statements/Insert.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ extension PrimaryKeyedTable {
598598
}
599599
}
600600

601-
private enum InsertValues {
601+
private enum InsertValues: Sendable {
602602
case `default`
603603
case values([[QueryFragment]])
604604
case select(QueryFragment)
@@ -611,7 +611,7 @@ private enum InsertValues {
611611
/// functions.
612612
///
613613
/// To learn more, see <doc:InsertStatements>.
614-
public struct Insert<Into: Table, Returning> {
614+
public struct Insert<Into: Table, Returning>: Sendable {
615615
var conflictResolution: ConflictResolution?
616616
var columnNames: [String]
617617
var conflictTargetColumnNames: [String]

Sources/StructuredQueriesCore/Statements/Select.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ extension Select: SelectStatement {
14211421
var query: QueryFragment = "SELECT"
14221422
let columns =
14231423
columns.isEmpty
1424-
? [From.columns.queryFragment] + joins.map { $0.table.columns.queryFragment }
1424+
? [From.columns.queryFragment] + joins.map(\.columns)
14251425
: columns.map(\.queryFragment)
14261426
if distinct {
14271427
query.append(" DISTINCT")
@@ -1472,26 +1472,30 @@ public struct _JoinClause: QueryExpression, Sendable {
14721472
}
14731473

14741474
let `operator`: QueryFragment?
1475-
let table: any Table.Type
1475+
let tableName: String
1476+
let tableAlias: String?
14761477
let constraint: QueryFragment
1478+
let columns: QueryFragment
14771479

1478-
init(
1480+
init<T: Table>(
14791481
operator: Operator?,
1480-
table: any Table.Type,
1482+
table: T.Type,
14811483
constraint: some QueryExpression<Bool>
14821484
) {
14831485
self.operator = `operator`?.queryFragment
1484-
self.table = table
1486+
self.tableName = table.tableName
1487+
self.tableAlias = table.tableAlias
14851488
self.constraint = constraint.queryFragment
1489+
self.columns = table.columns.queryFragment
14861490
}
14871491

14881492
public var queryFragment: QueryFragment {
14891493
var query: QueryFragment = ""
14901494
if let `operator` {
14911495
query.append("\(`operator`) ")
14921496
}
1493-
query.append("JOIN \(quote: table.tableName) ")
1494-
if let tableAlias = table.tableAlias {
1497+
query.append("JOIN \(quote: tableName) ")
1498+
if let tableAlias {
14951499
query.append("AS \(quote: tableAlias) ")
14961500
}
14971501
query.append("ON \(constraint)")

Sources/StructuredQueriesCore/Statements/Update.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ extension PrimaryKeyedTable {
9090
/// ``Where/update(or:set:)``.
9191
///
9292
/// To learn more, see <doc:UpdateStatements>.
93-
public struct Update<From: Table, Returning> {
93+
public struct Update<From: Table, Returning>: Sendable {
9494
var conflictResolution: ConflictResolution?
9595
var updates: Updates<From>
9696
var `where`: [QueryFragment] = []

Sources/StructuredQueriesCore/Statements/Values.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
///
1111
/// While not particularly useful on its own it can act as a helpful starting point for recursive
1212
/// common table expressions and other subqueries. See <doc:CommonTableExpressions> for more.
13-
public struct Values<QueryValue>: PartialSelectStatement {
13+
public struct Values<QueryValue>: PartialSelectStatement, Sendable {
1414
public typealias From = Never
1515

1616
let values: [QueryFragment]

0 commit comments

Comments
 (0)