Coding strategies are Sendable

This commit is contained in:
Gwendal Roué committed 2024-08-25 15:14:43 +02:00
1 parent 8e860e671b
commit 876a0870ee
3 files changed
+18 -18

No files matched your search

+6 -6
View File
@@ -474,7 +474,7 @@ extension Row {
/// var jsonData: Data
/// }
/// ```
public enum DatabaseDataEncodingStrategy {
public enum DatabaseDataEncodingStrategy: Sendable {
/// Encodes `Data` columns as SQL blob.
case deferredToData
@@ -482,7 +482,7 @@ public enum DatabaseDataEncodingStrategy {
case text
/// Encodes `Data` column as the result of the user-provided function.
case custom((Data) -> (any DatabaseValueConvertible)?)
case custom(@Sendable (Data) -> (any DatabaseValueConvertible)?)
func encode(_ data: Data) -> DatabaseValue {
switch self {
@@ -518,7 +518,7 @@ public enum DatabaseDataEncodingStrategy {
/// var creationDate: Date
/// }
/// ```
public enum DatabaseDateEncodingStrategy {
public enum DatabaseDateEncodingStrategy: Sendable {
/// The strategy that uses formatting from the Date structure.
///
/// It encodes dates using the format "YYYY-MM-DD HH:MM:SS.SSS" in the
@@ -548,7 +548,7 @@ public enum DatabaseDateEncodingStrategy {
case formatted(DateFormatter)
/// Encodes the result of the user-provided function
case custom((Date) -> (any DatabaseValueConvertible)?)
case custom(@Sendable (Date) -> (any DatabaseValueConvertible)?)
private static let iso8601Formatter: ISO8601DateFormatter = {
let formatter = ISO8601DateFormatter()
@@ -638,7 +638,7 @@ public enum DatabaseUUIDEncodingStrategy: Sendable {
/// var playerID: String
/// }
/// ```
public enum DatabaseColumnEncodingStrategy {
public enum DatabaseColumnEncodingStrategy: Sendable {
/// A key encoding strategy that doesn’t change key names during encoding.
case useDefaultKeys
@@ -646,7 +646,7 @@ public enum DatabaseColumnEncodingStrategy {
case convertToSnakeCase
/// A key encoding strategy defined by the closure you supply.
case custom((any CodingKey) -> String)
case custom(@Sendable (any CodingKey) -> String)
func column(forKey key: some CodingKey) -> String {
switch self {
+6 -6
View File
@@ -882,7 +882,7 @@ extension RecordCursor: Sendable { }
/// var myData: Data
/// }
/// ```
public enum DatabaseDataDecodingStrategy {
public enum DatabaseDataDecodingStrategy: Sendable {
/// Decodes `Data` columns from SQL blobs and UTF8 text.
case deferredToData
@@ -891,7 +891,7 @@ public enum DatabaseDataDecodingStrategy {
/// If the database value does not contain a suitable value, the function
/// must return nil (GRDB will interpret this nil result as a conversion
/// error, and react accordingly).
case custom((DatabaseValue) -> Data?)
case custom(@Sendable (DatabaseValue) -> Data?)
}
// MARK: - DatabaseDateDecodingStrategy
@@ -910,7 +910,7 @@ public enum DatabaseDataDecodingStrategy {
/// var name: String
/// var registrationDate: Date // decoded from epoch timestamp
/// }
public enum DatabaseDateDecodingStrategy {
public enum DatabaseDateDecodingStrategy: Sendable {
/// The strategy that uses formatting from the Date structure.
///
/// It decodes numeric values as a number of seconds since Epoch
@@ -951,7 +951,7 @@ public enum DatabaseDateDecodingStrategy {
/// If the database value does not contain a suitable value, the function
/// must return nil (GRDB will interpret this nil result as a conversion
/// error, and react accordingly).
case custom((DatabaseValue) -> Date?)
case custom(@Sendable (DatabaseValue) -> Date?)
}
// MARK: - DatabaseColumnDecodingStrategy
@@ -968,7 +968,7 @@ public enum DatabaseDateDecodingStrategy {
/// // Decoded from the player_id column
/// var playerID: Int
/// }
public enum DatabaseColumnDecodingStrategy {
public enum DatabaseColumnDecodingStrategy: Sendable {
/// A key decoding strategy that doesn’t change key names during decoding.
case useDefaultKeys
@@ -976,7 +976,7 @@ public enum DatabaseColumnDecodingStrategy {
case convertFromSnakeCase
/// A key decoding strategy defined by the closure you supply.
case custom((String) -> CodingKey)
case custom(@Sendable (String) -> CodingKey)
func key<K: CodingKey>(forColumn column: String) -> K? {
switch self {
+6 -6
View File
@@ -96,12 +96,12 @@
- [X] GRDB7: Sendable: BusyMode (e0d8e20b)
- [X] GRDB7: Sendable: TransactionClock (f7dc72a5)
- [X] GRDB7: Sendable: Configuration (54ffb21f)
- [ ] GRDB7: Sendable: DatabaseDataEncodingStrategy (264d7fb5)
- [ ] GRDB7: Sendable: DatabaseDateEncodingStrategy (264d7fb5)
- [ ] GRDB7: Sendable: DatabaseColumnEncodingStrategy (264d7fb5)
- [ ] GRDB7: Sendable: DatabaseDataDecodingStrategy (264d7fb5)
- [ ] GRDB7: Sendable: DatabaseDateDecodingStrategy (264d7fb5)
- [ ] GRDB7: Sendable: DatabaseColumnDecodingStrategy (264d7fb5)
- [X] GRDB7: Sendable: DatabaseDataEncodingStrategy (264d7fb5)
- [X] GRDB7: Sendable: DatabaseDateEncodingStrategy (264d7fb5)
- [X] GRDB7: Sendable: DatabaseColumnEncodingStrategy (264d7fb5)
- [X] GRDB7: Sendable: DatabaseDataDecodingStrategy (264d7fb5)
- [X] GRDB7: Sendable: DatabaseDateDecodingStrategy (264d7fb5)
- [X] GRDB7: Sendable: DatabaseColumnDecodingStrategy (264d7fb5)
- [X] GRDB7/BREAKING: Remove DatabaseFuture and concurrentRead (05f7d3c8)
- [ ] GRDB7: Sendable: DatabaseFunction (6e691fe7)
- [ ] GRDB7: Sendable: DatabaseMigrator (22114ad4)