Skip to content

Commit 618e72d

Browse files
authored
Merge pull request #1729 from groue/dev/issue-1728
Deprecate Date coding strategies based on DateFormatter
2 parents c7205b1 + 8241009 commit 618e72d

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

GRDB/Record/EncodableRecord.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,12 @@ public enum DatabaseDataEncodingStrategy: Sendable {
524524
/// var creationDate: Date
525525
/// }
526526
/// ```
527-
public enum DatabaseDateEncodingStrategy: Sendable {
527+
public enum DatabaseDateEncodingStrategy: @unchecked Sendable {
528+
// @unchecked Sendable because of `DateFormatter`, which lost its
529+
// `Sendable` conformance with Xcode 16.3. See
530+
// <https://github.com/swiftlang/swift/issues/78635>.
531+
// TODO GRDB8: remove @unchecked when the .formatted case has been removed.
532+
528533
/// The strategy that uses formatting from the Date structure.
529534
///
530535
/// It encodes dates using the format "YYYY-MM-DD HH:MM:SS.SSS" in the
@@ -551,6 +556,7 @@ public enum DatabaseDateEncodingStrategy: Sendable {
551556
case iso8601
552557

553558
/// Encodes a String, according to the provided formatter
559+
@available(*, deprecated, message: "Use .custom and a Date.FormatStyle instead.")
554560
case formatted(DateFormatter)
555561

556562
/// Encodes the result of the user-provided function

GRDB/Record/FetchableRecord.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,12 @@ public enum DatabaseDataDecodingStrategy: Sendable {
929929
/// var name: String
930930
/// var registrationDate: Date // decoded from epoch timestamp
931931
/// }
932-
public enum DatabaseDateDecodingStrategy: Sendable {
932+
public enum DatabaseDateDecodingStrategy: @unchecked Sendable {
933+
// @unchecked Sendable because of `DateFormatter`, which lost its
934+
// `Sendable` conformance with Xcode 16.3. See
935+
// <https://github.com/swiftlang/swift/issues/78635>.
936+
// TODO GRDB8: remove @unchecked when the .formatted case has been removed.
937+
933938
/// The strategy that uses formatting from the Date structure.
934939
///
935940
/// It decodes numeric values as a number of seconds since Epoch
@@ -963,6 +968,7 @@ public enum DatabaseDateDecodingStrategy: Sendable {
963968
case iso8601
964969

965970
/// Decodes a String, according to the provided formatter
971+
@available(*, deprecated, message: "Use .custom and a Date.FormatStyle instead.")
966972
case formatted(DateFormatter)
967973

968974
/// Decodes according to the user-provided function.

Tests/GRDBTests/DatabaseDateDecodingStrategyTests.swift

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ private enum StrategyIso8601: StrategyProvider {
2626
static let strategy: DatabaseDateDecodingStrategy = .iso8601
2727
}
2828

29+
@available(*, deprecated)
2930
private enum StrategyFormatted: StrategyProvider {
3031
static let strategy: DatabaseDateDecodingStrategy = .formatted({
3132
let formatter = DateFormatter()
@@ -418,6 +419,7 @@ extension DatabaseDateDecodingStrategyTests {
418419
// MARK: - formatted(DateFormatter)
419420

420421
extension DatabaseDateDecodingStrategyTests {
422+
@available(*, deprecated)
421423
func testFormatted() throws {
422424
try makeDatabaseQueue().read { db in
423425
var calendar = Calendar(identifier: .gregorian)

Tests/GRDBTests/DatabaseDateEncodingStrategyTests.swift

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ private enum StrategyIso8601: StrategyProvider {
3030
static let strategy: DatabaseDateEncodingStrategy = .iso8601
3131
}
3232

33+
@available(*, deprecated)
3334
private enum StrategyFormatted: StrategyProvider {
3435
static let strategy: DatabaseDateEncodingStrategy = .formatted({
3536
let formatter = DateFormatter()
@@ -197,6 +198,7 @@ extension DatabaseDateEncodingStrategyTests {
197198
// MARK: - formatted(DateFormatter)
198199

199200
extension DatabaseDateEncodingStrategyTests {
201+
@available(*, deprecated)
200202
func testFormatted() throws {
201203
try testNullEncoding(strategy: StrategyFormatted.self)
202204

0 commit comments

Comments
 (0)