From b079136cd51ea51de368d75dff976d36fc931391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 14 Sep 2024 17:24:16 +0200 Subject: [PATCH] Fix compiler warnings about ISO8601DateFormatter concurrency --- GRDB/Record/EncodableRecord.swift | 3 ++- GRDB/Record/FetchableRecord+Decodable.swift | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/GRDB/Record/EncodableRecord.swift b/GRDB/Record/EncodableRecord.swift index dd91c7586..f804f3d40 100644 --- a/GRDB/Record/EncodableRecord.swift +++ b/GRDB/Record/EncodableRecord.swift @@ -533,7 +533,8 @@ public enum DatabaseDateEncodingStrategy: Sendable { /// Encodes the result of the user-provided function case custom(@Sendable (Date) -> (any DatabaseValueConvertible)?) - private static let iso8601Formatter: ISO8601DateFormatter = { + // Assume this non-Sendable instance can be used from multiple threads concurrently. + nonisolated(unsafe) private static let iso8601Formatter: ISO8601DateFormatter = { let formatter = ISO8601DateFormatter() formatter.formatOptions = .withInternetDateTime return formatter diff --git a/GRDB/Record/FetchableRecord+Decodable.swift b/GRDB/Record/FetchableRecord+Decodable.swift index 8edca5d32..a4c6e423b 100644 --- a/GRDB/Record/FetchableRecord+Decodable.swift +++ b/GRDB/Record/FetchableRecord+Decodable.swift @@ -676,7 +676,8 @@ extension ColumnDecoder: SingleValueDecodingContainer { } } -private let iso8601Formatter: ISO8601DateFormatter = { +// Assume this non-Sendable instance can be used from multiple threads concurrently. +nonisolated(unsafe) private let iso8601Formatter: ISO8601DateFormatter = { let formatter = ISO8601DateFormatter() formatter.formatOptions = .withInternetDateTime return formatter