mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
Merge pull request #1729 from groue/dev/issue-1728
Deprecate Date coding strategies based on DateFormatter
This commit is contained in:
4 files changed
+18
-2
No files matched your search
@@ -524,7 +524,12 @@ public enum DatabaseDataEncodingStrategy: Sendable {
|
||||
/// var creationDate: Date
|
||||
/// }
|
||||
/// ```
|
||||
public enum DatabaseDateEncodingStrategy: Sendable {
|
||||
public enum DatabaseDateEncodingStrategy: @unchecked Sendable {
|
||||
// @unchecked Sendable because of `DateFormatter`, which lost its
|
||||
// `Sendable` conformance with Xcode 16.3. See
|
||||
// <https://github.com/swiftlang/swift/issues/78635>.
|
||||
// TODO GRDB8: remove @unchecked when the .formatted case has been removed.
|
||||
|
||||
/// The strategy that uses formatting from the Date structure.
|
||||
///
|
||||
/// It encodes dates using the format "YYYY-MM-DD HH:MM:SS.SSS" in the
|
||||
@@ -551,6 +556,7 @@ public enum DatabaseDateEncodingStrategy: Sendable {
|
||||
case iso8601
|
||||
|
||||
/// Encodes a String, according to the provided formatter
|
||||
@available(*, deprecated, message: "Use .custom and a Date.FormatStyle instead.")
|
||||
case formatted(DateFormatter)
|
||||
|
||||
/// Encodes the result of the user-provided function
|
||||
|
||||
@@ -929,7 +929,12 @@ public enum DatabaseDataDecodingStrategy: Sendable {
|
||||
/// var name: String
|
||||
/// var registrationDate: Date // decoded from epoch timestamp
|
||||
/// }
|
||||
public enum DatabaseDateDecodingStrategy: Sendable {
|
||||
public enum DatabaseDateDecodingStrategy: @unchecked Sendable {
|
||||
// @unchecked Sendable because of `DateFormatter`, which lost its
|
||||
// `Sendable` conformance with Xcode 16.3. See
|
||||
// <https://github.com/swiftlang/swift/issues/78635>.
|
||||
// TODO GRDB8: remove @unchecked when the .formatted case has been removed.
|
||||
|
||||
/// The strategy that uses formatting from the Date structure.
|
||||
///
|
||||
/// It decodes numeric values as a number of seconds since Epoch
|
||||
@@ -963,6 +968,7 @@ public enum DatabaseDateDecodingStrategy: Sendable {
|
||||
case iso8601
|
||||
|
||||
/// Decodes a String, according to the provided formatter
|
||||
@available(*, deprecated, message: "Use .custom and a Date.FormatStyle instead.")
|
||||
case formatted(DateFormatter)
|
||||
|
||||
/// Decodes according to the user-provided function.
|
||||
|
||||
@@ -26,6 +26,7 @@ private enum StrategyIso8601: StrategyProvider {
|
||||
static let strategy: DatabaseDateDecodingStrategy = .iso8601
|
||||
}
|
||||
|
||||
@available(*, deprecated)
|
||||
private enum StrategyFormatted: StrategyProvider {
|
||||
static let strategy: DatabaseDateDecodingStrategy = .formatted({
|
||||
let formatter = DateFormatter()
|
||||
@@ -418,6 +419,7 @@ extension DatabaseDateDecodingStrategyTests {
|
||||
// MARK: - formatted(DateFormatter)
|
||||
|
||||
extension DatabaseDateDecodingStrategyTests {
|
||||
@available(*, deprecated)
|
||||
func testFormatted() throws {
|
||||
try makeDatabaseQueue().read { db in
|
||||
var calendar = Calendar(identifier: .gregorian)
|
||||
|
||||
@@ -30,6 +30,7 @@ private enum StrategyIso8601: StrategyProvider {
|
||||
static let strategy: DatabaseDateEncodingStrategy = .iso8601
|
||||
}
|
||||
|
||||
@available(*, deprecated)
|
||||
private enum StrategyFormatted: StrategyProvider {
|
||||
static let strategy: DatabaseDateEncodingStrategy = .formatted({
|
||||
let formatter = DateFormatter()
|
||||
@@ -197,6 +198,7 @@ extension DatabaseDateEncodingStrategyTests {
|
||||
// MARK: - formatted(DateFormatter)
|
||||
|
||||
extension DatabaseDateEncodingStrategyTests {
|
||||
@available(*, deprecated)
|
||||
func testFormatted() throws {
|
||||
try testNullEncoding(strategy: StrategyFormatted.self)
|
||||
|
||||
|
||||
Reference in new issue
Block a user