diff --git a/Sources/CoreDataRepository/IdentifiedUnmanagedModel.swift b/Sources/CoreDataRepository/IdentifiedUnmanagedModel.swift index dece4d2..7e22ae2 100644 --- a/Sources/CoreDataRepository/IdentifiedUnmanagedModel.swift +++ b/Sources/CoreDataRepository/IdentifiedUnmanagedModel.swift @@ -8,14 +8,14 @@ import CoreData public protocol IdentifiedUnmanagedModel: ReadableUnmanagedModel { associatedtype UnmanagedId: Equatable - static var unmanagedIdAccessor: (Self) -> UnmanagedId { get } + var unmanagedId: UnmanagedId { get } static var managedIdExpression: NSExpression { get } } extension IdentifiedUnmanagedModel { @inlinable public func readManaged(from context: NSManagedObjectContext) throws -> ManagedModel { - try Self.readManaged(id: Self.unmanagedIdAccessor(self), from: context) + try Self.readManaged(id: unmanagedId, from: context) } @inlinable diff --git a/Sources/Internal/ModelsWithIntId/IdentifiableModel_Int.swift b/Sources/Internal/ModelsWithIntId/IdentifiableModel_Int.swift index 9d7cc85..110036e 100644 --- a/Sources/Internal/ModelsWithIntId/IdentifiableModel_Int.swift +++ b/Sources/Internal/ModelsWithIntId/IdentifiableModel_Int.swift @@ -100,7 +100,10 @@ extension IdentifiableModel_IntId: IdentifiedUnmanagedModel { } @inlinable - package static var unmanagedIdAccessor: (IdentifiableModel_IntId) -> Int { \.id } + package var unmanagedId: Int { + id + } + package nonisolated(unsafe) static let managedIdExpression = NSExpression(forKeyPath: \ManagedModel_IntId.id) } diff --git a/Sources/Internal/ModelsWithUuidId/IdentifiableModel_Uuid.swift b/Sources/Internal/ModelsWithUuidId/IdentifiableModel_Uuid.swift index 853038a..3e928ba 100644 --- a/Sources/Internal/ModelsWithUuidId/IdentifiableModel_Uuid.swift +++ b/Sources/Internal/ModelsWithUuidId/IdentifiableModel_Uuid.swift @@ -100,7 +100,10 @@ extension IdentifiableModel_UuidId: IdentifiedUnmanagedModel { } @inlinable - package static var unmanagedIdAccessor: (IdentifiableModel_UuidId) -> UUID { \.id } + package var unmanagedId: UUID { + id + } + package nonisolated(unsafe) static let managedIdExpression = NSExpression(forKeyPath: \ManagedModel_UuidId.id) } diff --git a/Tests/CoreDataRepositoryTests/BatchRequestTests.swift b/Tests/CoreDataRepositoryTests/BatchRequestTests.swift index cba3de5..e5e7c6c 100644 --- a/Tests/CoreDataRepositoryTests/BatchRequestTests.swift +++ b/Tests/CoreDataRepositoryTests/BatchRequestTests.swift @@ -159,7 +159,7 @@ extension CoreDataRepositoryTests { let count = try repositoryContext.count(for: fetchRequest) expectNoDifference(count, 0, "Count of objects in CoreData should be zero at the start of each test.") - let _ = try values + _ = try values .map(mapDictToManagedModel(_:)) try repositoryContext.save() } @@ -207,7 +207,7 @@ extension CoreDataRepositoryTests { let count = try repositoryContext.count(for: fetchRequest) expectNoDifference(count, 0, "Count of objects in CoreData should be zero at the start of each test.") - let _ = try values + _ = try values .map(mapDictToManagedModel(_:)) try repositoryContext.save() }