diff --git a/GRDB/Record/FetchableRecord.swift b/GRDB/Record/FetchableRecord.swift index 49d6ad720..3e54a2757 100644 --- a/GRDB/Record/FetchableRecord.swift +++ b/GRDB/Record/FetchableRecord.swift @@ -421,7 +421,7 @@ public enum DatabaseDateDecodingStrategy { /// (midnight UTC on January 1st, 1970). /// /// It decodes strings in the following formats, assuming UTC time zone. - /// Missing components are assumed to be zero. + /// Missing components are assumed to be zero: /// /// - `YYYY-MM-DD` /// - `YYYY-MM-DD HH:MM` diff --git a/GRDB/Record/PersistableRecord.swift b/GRDB/Record/PersistableRecord.swift index ff14837e4..750c7a547 100644 --- a/GRDB/Record/PersistableRecord.swift +++ b/GRDB/Record/PersistableRecord.swift @@ -995,7 +995,8 @@ extension PersistableRecord { public enum DatabaseDateEncodingStrategy { /// The strategy that uses formatting from the Date structure. /// - /// It encodes dates using the format "YYYY-MM-DD HH:MM:SS.SSS" in the UTC time zone. + /// It encodes dates using the format "YYYY-MM-DD HH:MM:SS.SSS" in the + /// UTC time zone. case deferredToDate /// Encodes a Double: the number of seconds between the date and @@ -1041,10 +1042,10 @@ public enum DatabaseDateEncodingStrategy { public enum DatabaseUUIDEncodingStrategy { /// The strategy that uses formatting from the UUID type. /// - /// It can encodes UUIDs as 16-bytes data blobs. + /// It encodes UUIDs as 16-bytes data blobs. case deferredToUUID - /// Encode UUIDs as strings such as "E621E1F8-C36C-495A-93FC-0C247A3E6E5F" + /// Encodes UUIDs as strings such as "E621E1F8-C36C-495A-93FC-0C247A3E6E5F" case string } diff --git a/README.md b/README.md index af7294bf1..4eddd8e72 100644 --- a/README.md +++ b/README.md @@ -2690,7 +2690,9 @@ protocol MutablePersistableRecord { } ``` -See [DatabaseDateDecodingStrategy](https://groue.github.io/GRDB.swift/docs/3.2/Enums/DatabaseDateDecodingStrategy.html), [DatabaseDateEncodingStrategy](https://groue.github.io/GRDB.swift/docs/3.2/Enums/DatabaseDateEncodingStrategy.html), and [DatabaseUUIDEncodingStrategy](https://groue.github.io/GRDB.swift/docs/3.2/Enums/DatabaseUUIDEncodingStrategy.html) for more information. +See [DatabaseDateDecodingStrategy](https://groue.github.io/GRDB.swift/docs/3.2/Enums/DatabaseDateDecodingStrategy.html), [DatabaseDateEncodingStrategy](https://groue.github.io/GRDB.swift/docs/3.2/Enums/DatabaseDateEncodingStrategy.html), and [DatabaseUUIDEncodingStrategy](https://groue.github.io/GRDB.swift/docs/3.2/Enums/DatabaseUUIDEncodingStrategy.html) to learn about all available strategies. + +> :point_up: **Note**: there is no customization of uuid decoding, because UUID can already decode all its encoded variants (16-bytes blobs, and uuid strings). ### The userInfo Dictionary @@ -2719,7 +2721,7 @@ struct Player: FetchableRecord, Decodable { init(from decoder: Decoder) throws { // Print the decoder name let decoderName = decoder.userInfo[decoderName] as? String - print("Decoded from \(decoderName ?? "nil")") + print("Decoded from \(decoderName ?? "unknown decoder")") ... } } @@ -2745,6 +2747,8 @@ extension Player: FetchableRecord { let player = try Player.fetchOne(db, ...) ``` +> :point_up: **Note**: make sure the `databaseDecodingUserInfo` and `databaseEncodingUserInfo` properties are explicitly declared as `[CodingUserInfoKey: Any]`. If they are not, the Swift compiler may silently miss the protocol requirement, resulting in sticky empty userInfo. + ### Tip: Use Coding Keys as Columns @@ -3898,7 +3902,7 @@ let request = RestrictedPlayer.all() let request = ExtendedPlayer.all() ``` -> :point_up: **Note**: make sure the `databaseSelection` property is explicitly declared as `[SQLSelectable]`. If it is not, the Swift compiler may infer a type which may silently miss the protocol requirement, resulting in sticky `SELECT *` requests. To verify your setup, see the [How do I print a request as SQL?](#how-do-i-print-a-request-as-sql) FAQ. +> :point_up: **Note**: make sure the `databaseSelection` property is explicitly declared as `[SQLSelectable]`. If it is not, the Swift compiler may silently miss the protocol requirement, resulting in sticky `SELECT *` requests. To verify your setup, see the [How do I print a request as SQL?](#how-do-i-print-a-request-as-sql) FAQ. ## Expressions