mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
Coding strategies are Sendable
This commit is contained in:
1 parent
54ffb21fb8
commit
264d7fb52e
3 files changed
+19
-19
No files matched your search
@@ -466,7 +466,7 @@ extension Row {
|
|||||||
/// var jsonData: Data
|
/// var jsonData: Data
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
public enum DatabaseDataEncodingStrategy {
|
public enum DatabaseDataEncodingStrategy: Sendable {
|
||||||
/// Encodes `Data` columns as SQL blob.
|
/// Encodes `Data` columns as SQL blob.
|
||||||
case deferredToData
|
case deferredToData
|
||||||
|
|
||||||
@@ -474,7 +474,7 @@ public enum DatabaseDataEncodingStrategy {
|
|||||||
case text
|
case text
|
||||||
|
|
||||||
/// Encodes `Data` column as the result of the user-provided function.
|
/// 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 {
|
func encode(_ data: Data) -> DatabaseValue {
|
||||||
switch self {
|
switch self {
|
||||||
@@ -508,7 +508,7 @@ public enum DatabaseDataEncodingStrategy {
|
|||||||
/// var creationDate: Date
|
/// var creationDate: Date
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
public enum DatabaseDateEncodingStrategy {
|
public enum DatabaseDateEncodingStrategy: Sendable {
|
||||||
/// The strategy that uses formatting from the Date structure.
|
/// The strategy that uses formatting from the Date structure.
|
||||||
///
|
///
|
||||||
/// It encodes dates using the format "YYYY-MM-DD HH:MM:SS.SSS" in the
|
/// It encodes dates using the format "YYYY-MM-DD HH:MM:SS.SSS" in the
|
||||||
@@ -538,7 +538,7 @@ public enum DatabaseDateEncodingStrategy {
|
|||||||
case formatted(DateFormatter)
|
case formatted(DateFormatter)
|
||||||
|
|
||||||
/// Encodes the result of the user-provided function
|
/// Encodes the result of the user-provided function
|
||||||
case custom((Date) -> (any DatabaseValueConvertible)?)
|
case custom(@Sendable (Date) -> (any DatabaseValueConvertible)?)
|
||||||
|
|
||||||
private static let iso8601Formatter: ISO8601DateFormatter = {
|
private static let iso8601Formatter: ISO8601DateFormatter = {
|
||||||
let formatter = ISO8601DateFormatter()
|
let formatter = ISO8601DateFormatter()
|
||||||
@@ -626,7 +626,7 @@ public enum DatabaseUUIDEncodingStrategy: Sendable {
|
|||||||
/// var playerID: String
|
/// var playerID: String
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
public enum DatabaseColumnEncodingStrategy {
|
public enum DatabaseColumnEncodingStrategy: Sendable {
|
||||||
/// A key encoding strategy that doesn’t change key names during encoding.
|
/// A key encoding strategy that doesn’t change key names during encoding.
|
||||||
case useDefaultKeys
|
case useDefaultKeys
|
||||||
|
|
||||||
@@ -634,7 +634,7 @@ public enum DatabaseColumnEncodingStrategy {
|
|||||||
case convertToSnakeCase
|
case convertToSnakeCase
|
||||||
|
|
||||||
/// A key encoding strategy defined by the closure you supply.
|
/// 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 {
|
func column(forKey key: some CodingKey) -> String {
|
||||||
switch self {
|
switch self {
|
||||||
|
|||||||
@@ -880,7 +880,7 @@ extension RecordCursor: Sendable { }
|
|||||||
/// var myData: Data
|
/// var myData: Data
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
public enum DatabaseDataDecodingStrategy {
|
public enum DatabaseDataDecodingStrategy: Sendable {
|
||||||
/// Decodes `Data` columns from SQL blobs and UTF8 text.
|
/// Decodes `Data` columns from SQL blobs and UTF8 text.
|
||||||
case deferredToData
|
case deferredToData
|
||||||
|
|
||||||
@@ -889,7 +889,7 @@ public enum DatabaseDataDecodingStrategy {
|
|||||||
/// If the database value does not contain a suitable value, the function
|
/// If the database value does not contain a suitable value, the function
|
||||||
/// must return nil (GRDB will interpret this nil result as a conversion
|
/// must return nil (GRDB will interpret this nil result as a conversion
|
||||||
/// error, and react accordingly).
|
/// error, and react accordingly).
|
||||||
case custom((DatabaseValue) -> Data?)
|
case custom(@Sendable (DatabaseValue) -> Data?)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - DatabaseDateDecodingStrategy
|
// MARK: - DatabaseDateDecodingStrategy
|
||||||
@@ -906,7 +906,7 @@ public enum DatabaseDataDecodingStrategy {
|
|||||||
/// var name: String
|
/// var name: String
|
||||||
/// var registrationDate: Date // decoded from epoch timestamp
|
/// var registrationDate: Date // decoded from epoch timestamp
|
||||||
/// }
|
/// }
|
||||||
public enum DatabaseDateDecodingStrategy {
|
public enum DatabaseDateDecodingStrategy: Sendable {
|
||||||
/// The strategy that uses formatting from the Date structure.
|
/// The strategy that uses formatting from the Date structure.
|
||||||
///
|
///
|
||||||
/// It decodes numeric values as a number of seconds since Epoch
|
/// It decodes numeric values as a number of seconds since Epoch
|
||||||
@@ -947,7 +947,7 @@ public enum DatabaseDateDecodingStrategy {
|
|||||||
/// If the database value does not contain a suitable value, the function
|
/// If the database value does not contain a suitable value, the function
|
||||||
/// must return nil (GRDB will interpret this nil result as a conversion
|
/// must return nil (GRDB will interpret this nil result as a conversion
|
||||||
/// error, and react accordingly).
|
/// error, and react accordingly).
|
||||||
case custom((DatabaseValue) -> Date?)
|
case custom(@Sendable (DatabaseValue) -> Date?)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - DatabaseColumnDecodingStrategy
|
// MARK: - DatabaseColumnDecodingStrategy
|
||||||
@@ -964,7 +964,7 @@ public enum DatabaseDateDecodingStrategy {
|
|||||||
/// // Decoded from the player_id column
|
/// // Decoded from the player_id column
|
||||||
/// var playerID: Int
|
/// var playerID: Int
|
||||||
/// }
|
/// }
|
||||||
public enum DatabaseColumnDecodingStrategy {
|
public enum DatabaseColumnDecodingStrategy: Sendable {
|
||||||
/// A key decoding strategy that doesn’t change key names during decoding.
|
/// A key decoding strategy that doesn’t change key names during decoding.
|
||||||
case useDefaultKeys
|
case useDefaultKeys
|
||||||
|
|
||||||
@@ -972,7 +972,7 @@ public enum DatabaseColumnDecodingStrategy {
|
|||||||
case convertFromSnakeCase
|
case convertFromSnakeCase
|
||||||
|
|
||||||
/// A key decoding strategy defined by the closure you supply.
|
/// 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? {
|
func key<K: CodingKey>(forColumn column: String) -> K? {
|
||||||
switch self {
|
switch self {
|
||||||
|
|||||||
@@ -115,12 +115,12 @@
|
|||||||
- [ ] databaseaggregate
|
- [ ] databaseaggregate
|
||||||
- [ ] databasecancellable
|
- [ ] databasecancellable
|
||||||
- [ ] databasecollation
|
- [ ] databasecollation
|
||||||
- [ ] databasecolumndecodingstrategy
|
- [X] databasecolumndecodingstrategy
|
||||||
- [ ] databasecolumnencodingstrategy
|
- [X] databasecolumnencodingstrategy
|
||||||
- [ ] databasedatadecodingstrategy
|
- [X] databasedatadecodingstrategy
|
||||||
- [ ] databasedataencodingstrategy
|
- [X] databasedataencodingstrategy
|
||||||
- [ ] databasedatedecodingstrategy
|
- [X] databasedatedecodingstrategy
|
||||||
- [ ] databasedateencodingstrategy
|
- [X] databasedateencodingstrategy
|
||||||
- [ ] databasefunction
|
- [ ] databasefunction
|
||||||
- [ ] databasefuture
|
- [ ] databasefuture
|
||||||
- [ ] databasemigrator
|
- [ ] databasemigrator
|
||||||
@@ -130,7 +130,7 @@
|
|||||||
- [ ] databasepublishers/value
|
- [ ] databasepublishers/value
|
||||||
- [ ] databasepublishers/write
|
- [ ] databasepublishers/write
|
||||||
- [ ] databaseregionobservation
|
- [ ] databaseregionobservation
|
||||||
- [ ] databaseuuidencodingstrategy
|
- [X] databaseuuidencodingstrategy
|
||||||
- [X] defaulttransactionclock
|
- [X] defaulttransactionclock
|
||||||
- [ ] fetchablerecorddecoder
|
- [ ] fetchablerecorddecoder
|
||||||
- [ ] fetchrequest
|
- [ ] fetchrequest
|
||||||
|
|||||||
Reference in new issue
Block a user