Skip to content

Commit 0fd1b27

Browse files
Drop Sendable requirements in protocols (#128)
* Remove a bunch of sendable requirements. * wip * wip * sendable select * wip * wip * wip * wip * wip --------- Co-authored-by: Stephen Celis <[email protected]>
1 parent bb12b34 commit 0fd1b27

File tree

17 files changed

+423
-272
lines changed

17 files changed

+423
-272
lines changed

Package.resolved

Lines changed: 3 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/StructuredQueriesCore/AggregateFunctions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ extension QueryExpression where Self == AggregateFunction<Int> {
209209
}
210210

211211
/// A query expression of an aggregate function.
212-
public struct AggregateFunction<QueryValue>: QueryExpression {
212+
public struct AggregateFunction<QueryValue>: QueryExpression, Sendable {
213213
var name: QueryFragment
214214
var isDistinct: Bool
215215
var arguments: [QueryFragment]

Sources/StructuredQueriesCore/Collation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
///
33
/// Values of this type are supplied to ``QueryExpression/collate(_:)`` to describe how a string
44
/// should be compared in a query.
5-
public struct Collation: QueryExpression {
5+
public struct Collation: QueryExpression, Sendable {
66
public typealias QueryValue = Never
77

88
/// Initializes a collating sequence name from a query fragment.

Sources/StructuredQueriesCore/Optional.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ extension Optional: Table where Wrapped: Table {
8080
}
8181

8282
fileprivate subscript<Member: QueryRepresentable>(
83-
member _: KeyPath<Member, Member> & Sendable,
84-
column keyPath: KeyPath<Wrapped, Member.QueryOutput> & Sendable
83+
member _: KeyPath<Member, Member>,
84+
column keyPath: KeyPath<Wrapped, Member.QueryOutput>
8585
) -> Member.QueryOutput? {
8686
self?[keyPath: keyPath]
8787
}

Sources/StructuredQueriesCore/QueryExpression.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// A type that represents a full or partial SQL query.
2-
public protocol QueryExpression<QueryValue>: Sendable {
2+
public protocol QueryExpression<QueryValue> {
33
/// The Swift data type representation of the expression's SQL data type.
44
///
55
/// For example, a `TEXT` expression may be represented as a `String` query value.

Sources/StructuredQueriesCore/QueryRepresentable/Codable+JSON.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public struct _CodableJSONRepresentation<QueryOutput: Codable & Sendable>: QueryRepresentable {
3+
public struct _CodableJSONRepresentation<QueryOutput: Codable>: QueryRepresentable {
44
public var queryOutput: QueryOutput
55

66
public init(queryOutput: QueryOutput) {

Sources/StructuredQueriesCore/SQLQueryExpression.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
///
33
/// It is not common to interact with this type directly. A value of this type is returned from the
44
/// `#sql` macro. See <doc:SafeSQLStrings> for more information.
5-
public struct SQLQueryExpression<QueryValue>: Statement {
5+
public struct SQLQueryExpression<QueryValue>: Sendable, Statement {
66
public typealias From = Never
77

88
public let queryFragment: QueryFragment

Sources/StructuredQueriesCore/SQLite/ConflictResolution.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// A conflict resolution algorithm.
2-
public struct ConflictResolution: QueryExpression {
2+
public struct ConflictResolution: QueryExpression, Sendable {
33
public typealias QueryValue = Never
44

55
/// The `ABORT` conflict resolution algorithm.

Sources/StructuredQueriesCore/SQLite/JSONFunctions.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ extension QueryExpression {
2020
/// ```
2121
///
2222
/// - Returns: An integer expression of the `json_array_length` function wrapping this expression.
23-
public func jsonArrayLength<Element: Codable & Sendable>() -> some QueryExpression<Int>
23+
public func jsonArrayLength<Element: Codable>() -> some QueryExpression<Int>
2424
where QueryValue == [Element].JSONRepresentation {
2525
QueryFunction("json_array_length", self)
2626
}
2727
}
2828

29-
extension QueryExpression where QueryValue: Codable & QueryBindable & Sendable {
29+
extension QueryExpression where QueryValue: Codable & QueryBindable {
3030
/// A JSON array aggregate of this expression
3131
///
3232
/// Concatenates all of the values in a group.
@@ -56,7 +56,7 @@ extension QueryExpression where QueryValue: Codable & QueryBindable & Sendable {
5656
}
5757
}
5858

59-
extension PrimaryKeyedTableDefinition where QueryValue: Codable & Sendable {
59+
extension PrimaryKeyedTableDefinition where QueryValue: Codable {
6060
/// A JSON array representation of the aggregation of a table's columns.
6161
///
6262
/// Constructs a JSON array of JSON objects with a field for each column of the table. This can be
@@ -122,7 +122,7 @@ extension PrimaryKeyedTableDefinition where QueryValue: Codable & Sendable {
122122
}
123123
}
124124

125-
extension PrimaryKeyedTableDefinition where QueryValue: _OptionalProtocol & Codable & Sendable {
125+
extension PrimaryKeyedTableDefinition where QueryValue: _OptionalProtocol & Codable {
126126
/// A JSON array representation of the aggregation of a table's columns.
127127
///
128128
/// Constructs a JSON array of JSON objects with a field for each column of the table. This can be
@@ -173,7 +173,7 @@ extension PrimaryKeyedTableDefinition where QueryValue: _OptionalProtocol & Coda
173173
/// - order: An `ORDER BY` clause to apply to the aggregation.
174174
/// - filter: A `FILTER` clause to apply to the aggregation.
175175
/// - Returns: A JSON array aggregate of this table.
176-
public func jsonGroupArray<Wrapped: Codable & Sendable>(
176+
public func jsonGroupArray<Wrapped: Codable>(
177177
isDistinct: Bool = false,
178178
order: (some QueryExpression)? = Bool?.none,
179179
filter: (some QueryExpression<Bool>)? = Bool?.none
@@ -195,18 +195,18 @@ extension PrimaryKeyedTableDefinition where QueryValue: _OptionalProtocol & Coda
195195
}
196196
}
197197

198-
extension TableDefinition where QueryValue: Codable & Sendable {
198+
extension TableDefinition where QueryValue: Codable {
199199
/// A JSON representation of a table's columns.
200200
///
201201
/// Useful for referencing a table row in a larger JSON selection.
202202
public func jsonObject() -> some QueryExpression<_CodableJSONRepresentation<QueryValue>> {
203203
func open<TableColumn: TableColumnExpression>(_ column: TableColumn) -> QueryFragment {
204204
typealias Value = TableColumn.QueryValue._Optionalized.Wrapped
205205

206-
func isJSONRepresentation<T: Codable & Sendable>(_: T.Type, isOptional: Bool = false) -> Bool
206+
func isJSONRepresentation<T: Codable>(_: T.Type, isOptional: Bool = false) -> Bool
207207
{
208208
func isOptionalJSONRepresentation<U: _OptionalProtocol>(_: U.Type) -> Bool {
209-
if let codableType = U.Wrapped.self as? any (Codable & Sendable).Type {
209+
if let codableType = U.Wrapped.self as? any Codable.Type {
210210
return isJSONRepresentation(codableType, isOptional: true)
211211
} else {
212212
return false
@@ -231,7 +231,7 @@ extension TableDefinition where QueryValue: Codable & Sendable {
231231
} else if Value.self == Date.JulianDayRepresentation.self {
232232
return "\(quote: column.name, delimiter: .text), datetime(\(column), 'julianday')"
233233
} else if let codableType = TableColumn.QueryValue.QueryOutput.self
234-
as? any (Codable & Sendable).Type,
234+
as? any Codable.Type,
235235
isJSONRepresentation(codableType)
236236
{
237237
return "\(quote: column.name, delimiter: .text), json(\(column))"
@@ -246,7 +246,7 @@ extension TableDefinition where QueryValue: Codable & Sendable {
246246
}
247247
}
248248

249-
extension Optional.TableColumns where QueryValue: Codable & Sendable {
249+
extension Optional.TableColumns where QueryValue: Codable {
250250
/// A JSON representation of a table's columns.
251251
///
252252
/// Useful for referencing a table row in a larger JSON selection.

Sources/StructuredQueriesCore/Statements/CommonTableExpression.swift

Lines changed: 2 additions & 2 deletions
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]
@@ -44,7 +44,7 @@ extension QueryFragment {
4444
fileprivate var presence: Self? { isEmpty ? nil : self }
4545
}
4646

47-
public struct CommonTableExpressionClause: QueryExpression {
47+
public struct CommonTableExpressionClause: QueryExpression, Sendable {
4848
public typealias QueryValue = ()
4949
let tableName: QueryFragment
5050
let select: QueryFragment

0 commit comments

Comments
 (0)