From cce418500f8a06e29579cf887678c6a93478f35d Mon Sep 17 00:00:00 2001 From: Andrew Roan Date: Thu, 9 Oct 2025 16:03:39 -0500 Subject: [PATCH 1/2] Fix name of IdentifiedUnmanagedModel.unmanagedIdExpression feature/fix-misnamed-property # Conflicts: # Sources/CoreDataRepository/IdentifiedUnmanagedModel.swift # Sources/Internal/ModelsWithIntId/IdentifiableModel_Int.swift # Sources/Internal/ModelsWithUuidId/IdentifiableModel_Uuid.swift --- Sources/CoreDataRepository/IdentifiedUnmanagedModel.swift | 5 +++-- Sources/Internal/ModelsWithIntId/IdentifiableModel_Int.swift | 2 +- .../Internal/ModelsWithUuidId/IdentifiableModel_Uuid.swift | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Sources/CoreDataRepository/IdentifiedUnmanagedModel.swift b/Sources/CoreDataRepository/IdentifiedUnmanagedModel.swift index dece4d2..e44f9b5 100644 --- a/Sources/CoreDataRepository/IdentifiedUnmanagedModel.swift +++ b/Sources/CoreDataRepository/IdentifiedUnmanagedModel.swift @@ -9,7 +9,8 @@ import CoreData public protocol IdentifiedUnmanagedModel: ReadableUnmanagedModel { associatedtype UnmanagedId: Equatable static var unmanagedIdAccessor: (Self) -> UnmanagedId { get } - static var managedIdExpression: NSExpression { get } + /// `NSExpression` for the `unmanagedId` property on `ManagedModel` + static var unmanagedIdExpression: NSExpression { get } } extension IdentifiedUnmanagedModel { @@ -22,7 +23,7 @@ extension IdentifiedUnmanagedModel { public static func readManaged(id: UnmanagedId, from context: NSManagedObjectContext) throws -> ManagedModel { let request = Self.managedFetchRequest() request.predicate = NSComparisonPredicate( - leftExpression: Self.managedIdExpression, + leftExpression: Self.unmanagedIdExpression, rightExpression: NSExpression(forConstantValue: id), modifier: .direct, type: .equalTo diff --git a/Sources/Internal/ModelsWithIntId/IdentifiableModel_Int.swift b/Sources/Internal/ModelsWithIntId/IdentifiableModel_Int.swift index 9d7cc85..9cfc6cd 100644 --- a/Sources/Internal/ModelsWithIntId/IdentifiableModel_Int.swift +++ b/Sources/Internal/ModelsWithIntId/IdentifiableModel_Int.swift @@ -101,7 +101,7 @@ extension IdentifiableModel_IntId: IdentifiedUnmanagedModel { @inlinable package static var unmanagedIdAccessor: (IdentifiableModel_IntId) -> Int { \.id } - package nonisolated(unsafe) static let managedIdExpression = NSExpression(forKeyPath: \ManagedModel_IntId.id) + package nonisolated(unsafe) static let unmanagedIdExpression = NSExpression(forKeyPath: \ManagedModel_IntId.id) } extension IdentifiableModel_IntId: WritableUnmanagedModel { diff --git a/Sources/Internal/ModelsWithUuidId/IdentifiableModel_Uuid.swift b/Sources/Internal/ModelsWithUuidId/IdentifiableModel_Uuid.swift index 853038a..86ea95f 100644 --- a/Sources/Internal/ModelsWithUuidId/IdentifiableModel_Uuid.swift +++ b/Sources/Internal/ModelsWithUuidId/IdentifiableModel_Uuid.swift @@ -101,7 +101,7 @@ extension IdentifiableModel_UuidId: IdentifiedUnmanagedModel { @inlinable package static var unmanagedIdAccessor: (IdentifiableModel_UuidId) -> UUID { \.id } - package nonisolated(unsafe) static let managedIdExpression = NSExpression(forKeyPath: \ManagedModel_UuidId.id) + package nonisolated(unsafe) static let unmanagedIdExpression = NSExpression(forKeyPath: \ManagedModel_UuidId.id) } extension IdentifiableModel_UuidId: WritableUnmanagedModel { From c7b8e858ed5a65f497e8fd4b0d1565dfd1c6e11b Mon Sep 17 00:00:00 2001 From: Andrew Roan Date: Thu, 9 Oct 2025 17:06:33 -0500 Subject: [PATCH 2/2] Run swiftformat feature/fix-misnamed-property --- Tests/CoreDataRepositoryTests/BatchRequestTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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() }