Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codable records: customize the userInfo context dictionary, and the format of JSON columns #399

Merged
merged 24 commits into from
Aug 19, 2018

Conversation

groue
Copy link
Owner

@groue groue commented Aug 16, 2018

This PR brings four customization points for Codable record types:

 protocol FetchableRecord {
+    static var databaseDecodingUserInfo: [CodingUserInfoKey: Any] { get }
+    static func databaseJSONDecoder(for column: String) -> JSONDecoder
 }

 protocol MutablePersistableRecord: TableRecord {
+    static var databaseEncodingUserInfo: [CodingUserInfoKey: Any] { get }
+    static func databaseJSONEncoder(for column: String) -> JSONEncoder
 }

The userInfo dictionaries address the feature request #324 by @samritchie.

The JSON encoder/decoders allow you to customize the format of JSON columns introduced in #397 (so that you can change the format of dates embedded in JSON, for example).

@groue groue changed the title Let record types set Encoder/Decoder userInfo keys Codable support: customize the userInfo context dictionary, and the format of JSON columns Aug 18, 2018
@groue groue force-pushed the feature/codableUserInfo branch from 6e8c161 to e9b7a67 Compare August 18, 2018 13:54
@groue groue merged commit 1fba575 into development Aug 19, 2018
@groue groue deleted the feature/codableUserInfo branch August 19, 2018 05:31
@groue groue changed the title Codable support: customize the userInfo context dictionary, and the format of JSON columns Codable records: customize the userInfo context dictionary, and the format of JSON columns Aug 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant