Skip to content

Commit b16d15c

Browse files
authored
fix: KeyPath crash when querying CareStore (#718)
* test outcome fix (cherry picked from commit 4f10b62) * make all sort descriptors use class keyPaths (cherry picked from commit 671cfa7)
1 parent d460d90 commit b16d15c

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

CareKitStore/CareKitStore/StoreCoordinator/OCKPersistentStoreCoordinator+Outcomes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extension OCKStoreCoordinator {
4545
}
4646

4747
let sortDescriptor = NSSortDescriptor(
48-
keyPath: \OCKAnyOutcome.id,
48+
keyPath: \OCKCDOutcome.id,
4949
ascending: true
5050
)
5151

CareKitStore/CareKitStore/Structs/Queries/OCKCarePlanQuery.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public struct OCKCarePlanQuery: Equatable, OCKQueryProtocol {
4242
var nsSortDescriptor: NSSortDescriptor {
4343
switch self {
4444
case let .effectiveDate(ascending):
45-
return NSSortDescriptor(keyPath: \OCKAnyCarePlan.effectiveDate, ascending: ascending)
45+
return NSSortDescriptor(keyPath: \OCKCDCarePlan.effectiveDate, ascending: ascending)
4646
case let .title(ascending):
47-
return NSSortDescriptor(keyPath: \OCKAnyCarePlan.title, ascending: ascending)
47+
return NSSortDescriptor(keyPath: \OCKCDCarePlan.title, ascending: ascending)
4848
}
4949
}
5050
}

CareKitStore/CareKitStore/Structs/Queries/OCKContactQuery.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public struct OCKContactQuery: Equatable, OCKQueryProtocol {
4343
var nsSortDescriptor: NSSortDescriptor {
4444
switch self {
4545
case let .effectiveDate(ascending):
46-
return NSSortDescriptor(keyPath: \OCKAnyContact.effectiveDate, ascending: ascending)
46+
return NSSortDescriptor(keyPath: \OCKCDContact.effectiveDate, ascending: ascending)
4747
case let .givenName(ascending):
48-
return NSSortDescriptor(keyPath: \OCKAnyContact.name.givenName, ascending: ascending)
48+
return NSSortDescriptor(keyPath: \OCKCDContact.name.givenName, ascending: ascending)
4949
case let .familyName(ascending):
50-
return NSSortDescriptor(keyPath: \OCKAnyContact.name.familyName, ascending: ascending)
50+
return NSSortDescriptor(keyPath: \OCKCDContact.name.familyName, ascending: ascending)
5151
}
5252
}
5353
}

CareKitStore/CareKitStore/Structs/Queries/OCKPatientQuery.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ public struct OCKPatientQuery: Equatable, OCKQueryProtocol {
4444
var nsSortDescriptor: NSSortDescriptor {
4545
switch self {
4646
case let .groupIdentifier(ascending):
47-
return NSSortDescriptor(keyPath: \OCKAnyPatient.groupIdentifier, ascending: ascending)
47+
return NSSortDescriptor(keyPath: \OCKCDPatient.groupIdentifier, ascending: ascending)
4848
case let .givenName(ascending):
49-
return NSSortDescriptor(keyPath: \OCKAnyPatient.name.givenName, ascending: ascending)
49+
return NSSortDescriptor(keyPath: \OCKCDPatient.name.givenName, ascending: ascending)
5050
case let .familyName(ascending):
51-
return NSSortDescriptor(keyPath: \OCKAnyPatient.name.familyName, ascending: ascending)
51+
return NSSortDescriptor(keyPath: \OCKCDPatient.name.familyName, ascending: ascending)
5252
case let .effectiveDate(ascending):
53-
return NSSortDescriptor(keyPath: \OCKAnyPatient.effectiveDate, ascending: ascending)
53+
return NSSortDescriptor(keyPath: \OCKCDPatient.effectiveDate, ascending: ascending)
5454
}
5555
}
5656
}

CareKitStore/CareKitStore/Structs/Queries/OCKTaskQuery.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ public struct OCKTaskQuery: Equatable, OCKQueryProtocol {
4444

4545
case let .effectiveDate(ascending):
4646
return NSSortDescriptor(
47-
keyPath: \OCKAnyTask.effectiveDate,
47+
keyPath: \OCKCDTask.effectiveDate,
4848
ascending: ascending
4949
)
5050

5151
case let .groupIdentifier(ascending):
5252
return NSSortDescriptor(
53-
keyPath: \OCKAnyTask.groupIdentifier,
53+
keyPath: \OCKCDTask.groupIdentifier,
5454
ascending: ascending
5555
)
5656

5757
case let .title(ascending):
5858
return NSSortDescriptor(
59-
keyPath: \OCKAnyTask.title,
59+
keyPath: \OCKCDTask.title,
6060
ascending: ascending
6161
)
6262
}

0 commit comments

Comments
 (0)