RestKit: RestKit 0.20.0rc1 change causes Core Data code to fail
Hello,
We have some code that was working under pre6, but now generates Core Data errors with rc1. Any help would be appreciated. We see the error both when we run our code and when we run the unit tests.
The managedObjectStore is empty when the test case runs.
Here is the error message in the console:
Test Case '-[RecipientRemoteServiceImplTest testEntityMappingInManagedObjectStore]' started.
2013-02-11 10:52:53.570 SomeClientApp[43169:1b03] Core Data: annotation: repairing missing delete propagation for to-many relationship recipients on object <ProfileModelCoreDataImpl: 0x8af63d0> (entity: ProfileModelCoreDataImpl; id: 0x8af6410 <x-coredata:///ProfileModelCoreDataImpl/tFB40588F-E4DF-4AE1-9459-144E2B1A468D38> ; data: {
address = "<AddressModelImpl: 0x8afb3d0>";
emailAddress = nil;
firstName = Jordan;
fullName = "Jordan Luis";
lastName = Luis;
maternalName = nil;
mobileNumber = nil;
phoneNumber = "555-555-5555";
profileID = "2TXLG5jPICrGA75Pn-MClg";
recipients = (
"0x8adf940 <x-coredata:///RecipientModelCoreDataImpl/tFB40588F-E4DF-4AE1-9459-144E2B1A468D35>"
);
transfers = (
"0x8aee8d0 <x-coredata:///TransferModelCoreDataImpl/tFB40588F-E4DF-4AE1-9459-144E2B1A468D36>"
);
userID = jG3wFXYTGIM7t6FAKha7wg;
users = (
);
}) with bad fault 0x8adf940 <x-coredata:///RecipientModelCoreDataImpl/tFB40588F-E4DF-4AE1-9459-144E2B1A468D35>
/Users/echamberlain/ArcTouch/SomeClient/mobile-ios/SomeClientApp/SomeClientAppTests/RecipientRemoteServiceImplTest.m:127: error: -[RecipientRemoteServiceImplTest testEntityMappingInManagedObjectStore] : Expected YES, error returned instead: Error Domain=NSCocoaErrorDomain Code=1570 "The operation couldn’t be completed. (Cocoa error 1570.)" UserInfo=0x14159940 {NSValidationErrorObject=<RecipientModelCoreDataImpl: 0x8adf8e0> (entity: RecipientModelCoreDataImpl; id: 0x8adf940 <x-coredata:///RecipientModelCoreDataImpl/tFB40588F-E4DF-4AE1-9459-144E2B1A468D35> ; data: {
deleted = 1;
lastCheckDate = "2013-02-11 18:52:53 +0000";
lastModified = "2012-09-11 19:45:00 +0000";
latestTransfer = "0x8aee8d0 <x-coredata:///TransferModelCoreDataImpl/tFB40588F-E4DF-4AE1-9459-144E2B1A468D36>";
profile = nil;
recipientID = 9EVeVWFB56mod8xGmzTmKg;
thumbnail = nil;
userID = jG3wFXYTGIM7t6FAKha7wg;
}), NSValidationErrorKey=profile, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1570.)}, but was <<RecipientModelCoreDataImpl: 0x8adf8e0> (entity: RecipientModelCoreDataImpl; id: 0x8adf940 <x-coredata:///RecipientModelCoreDataImpl/tFB40588F-E4DF-4AE1-9459-144E2B1A468D35> ; data: {
deleted = 1;
lastCheckDate = "2013-02-11 18:52:53 +0000";
lastModified = "2012-09-11 19:45:00 +0000";
latestTransfer = "0x8aee8d0 <x-coredata:///TransferModelCoreDataImpl/tFB40588F-E4DF-4AE1-9459-144E2B1A468D36>";
profile = nil;
recipientID = 9EVeVWFB56mod8xGmzTmKg;
thumbnail = nil;
userID = jG3wFXYTGIM7t6FAKha7wg;
})>
Test Case '-[RecipientRemoteServiceImplTest testEntityMappingInManagedObjectStore]' failed (0.075 seconds).
Here is the unit test:
- (void)testEntityMappingInManagedObjectStore {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
RKMappingTest *test = [self mappingTestforMapping:[[RecipientRemoteServiceImpl new] entityMappingInManagedObjectStore:[RKManagedObjectStore defaultStore]]
entityName:RecipientModelCoreDataImplEntityName
fixture:@"RecipientModel.json"
primaryKeyAttribute:RecipientModelRecipientID];
[test addExpectationForKeyPath:RecipientModelDeleted
value:[NSNumber numberWithBool:NO]];
[test addExpectationWithSourceKeyPath:RecipientMappingServiceImplLastModifiedKeyPath
destinationKeyPath:RecipientModelLastModified
value:[dateFormatter dateFromString:@"2012-09-11T19:45:00.000+0000"]];
[test addExpectationWithSourceKeyPath:RecipientModelLatestTransfer
destinationKeyPath:RecipientModelLatestTransfer
evaluationBlock:^BOOL(RKPropertyMappingTestExpectation *expectation,
RKPropertyMapping *mapping,
id mappedValue,
NSError *__autoreleasing *error) {
return [mappedValue conformsToProtocol:@protocol(TransferModel)];
}];
[test addExpectationWithSourceKeyPath:RecipientModelProfile
destinationKeyPath:RecipientModelProfile
evaluationBlock:^BOOL(RKPropertyMappingTestExpectation *expectation,
RKPropertyMapping *mapping,
id mappedValue,
NSError *__autoreleasing *error) {
return [mappedValue conformsToProtocol:@protocol(ProfileModel)];
}];
[test addExpectationWithSourceKeyPath:RecipientMappingServiceImplRecipientIDKeyPath
destinationKeyPath:RecipientModelRecipientID
value:@"9EVeVWFB56mod8xGmzTmKg"];
[test addExpectationWithSourceKeyPath:RecipientMappingServiceImplUserIDKeyPath
destinationKeyPath:RecipientModelUserID
value:@"jG3wFXYTGIM7t6FAKha7wg"];
Verify(test);
[test.destinationObject setLastCheckDate:[NSDate date]];
assertThat(test.destinationObject, validForInsert());
}
Here is what our test fixture looks like:
{
"id": "9EVeVWFB56mod8xGmzTmKg",
"userId": "jG3wFXYTGIM7t6FAKha7wg",
"profile": {
"id": "2TXLG5jPICrGA75Pn-MClg",
"userId": "jG3wFXYTGIM7t6FAKha7wg",
"firstName": "Jordan",
"lastName": "Luis",
"fullName": "Jordan Luis",
"country": "BR",
"maternalName": null,
"emailAddress": null
},
"modified": "2012-09-11T19:45:00.000+0000",
"deleted": false,
"latestTransfer": {
"id": "MQMgfbZfByFpb8zQim7rXQ",
"userId": "jG3wFXYTGIM7t6FAKha7wg",
"transactionNumber": "48797274883070",
"sent": "2012-09-11T19:45:00.000+0000",
"recipientProfile": {
"id": "2TXLG5jPICrGA75Pn-MClg",
"userId": "jG3wFXYTGIM7t6FAKha7wg",
"firstName": "Jordan",
"lastName": "Luis",
"fullName": "Jordan Luis",
"address": {
"address1": "41 Rosemont Place",
"address2": null,
"address3": null,
"neighborhood": null,
"city": "San Francisco",
"county": null,
"postalCode": null,
"region": null,
"state": {
"key": "MX-OAX",
"name": "Oaxaca"
},
"country": {
"key": "MX",
"name": "Mexico"
}
},
"phoneNumber": "555-555-5555",
"mobileNumber": null,
"maternalName": null,
"emailAddress": null
},
"Redacted..."
}
}
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 17 (10 by maintainers)
Commits related to this issue
- Rework deletion operations to avoid deleting objects that would be valid if mapping we allowed to assign them to the desintation relationship. refs #1225 — committed to RestKit/RestKit by blakewatters 11 years ago
- Rework deletion operations to avoid deleting objects that would be valid if mapping we allowed to assign them to the desintation relationship. refs #1225 — committed to CenterDevice/RestKit by blakewatters 11 years ago
Figured it out. So the deal is that the object is being deleted because it is invalid. It’s invalid because the deletion operation is executing before the object is assigned to the destination relationship, whose inverse may well make it valid. I have reworked the code to accommodate this situation. Please give it a try and let me know if the fix works in your app.