Skip to content

Commit a56b2d4

Browse files
committed
Provide more context when asserting OfflineStore objectId assignment issues
1 parent 49a0699 commit a56b2d4

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Parse/Parse/Internal/LocalDataStore/OfflineStore/PFOfflineStore.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,8 @@ - (void)updateObjectIdForObject:(PFObject *)object
10281028
// See if there's already an entry for new objectId.
10291029
PFObject *existing = [self.classNameAndObjectIdToObjectMap objectForKey:key];
10301030
PFConsistencyAssert(existing == nil || existing == object,
1031-
@"Attempted to change an objectId to one that's already known to the OfflineStore.");
1031+
@"Attempted to change an objectId to one that's already known to the OfflineStore. className: %@ old: %@, new: %@",
1032+
className, oldObjectId, newObjectId);
10321033

10331034
// Okay, all clear to add the new reference.
10341035
[self.classNameAndObjectIdToObjectMap setObject:object forKey:key];

Parse/Tests/Unit/QueryUnitTests.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,4 +1413,23 @@ - (void)testHash {
14131413
XCTAssertEqual([queryA hash], [queryB hash]);
14141414
}
14151415

1416+
- (void)testReproduceIssue1202 {
1417+
[[Parse _currentManager] clearEventuallyQueue];
1418+
[Parse _clearCurrentManager];
1419+
[Parse enableLocalDatastore];
1420+
[Parse setApplicationId:@"a" clientKey:@"b"];
1421+
PFObject *objectA = [PFObject objectWithClassName:@"Object" dictionary:@{@"objectId":@"yolo", @"key": @"value"}];
1422+
objectA.objectId = @"yolo";
1423+
PFObject *objectB = [PFObject objectWithClassName:@"Object" dictionary:@{@"objectId":@"yolo", @"key": @"value"}];
1424+
@try {
1425+
objectB.objectId = @"yolo";
1426+
XCTFail();
1427+
}
1428+
@catch (NSException *e) {
1429+
XCTAssertEqual(e.name, NSInternalInconsistencyException);
1430+
XCTAssertEqualObjects(e.reason, @"Attempted to change an objectId to one that's already known to the OfflineStore. className: Object old: (null), new: yolo");
1431+
}
1432+
}
1433+
1434+
14161435
@end

0 commit comments

Comments
 (0)