GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Occassionally (not every time) I get an error on NSManagedObject+MagicalDataImport.m Line 168 (I'm on the develop branch).
id relatedObjectData = [relationshipData valueForKeyPath:lookupKey];
But I'm not sure why it is getting here. Hopefully I'm not too verbose, but in hope of making this clear, let me explain what is happening with my code / MR.
I'm calling MR_importFromArray:inContext: for my entity called InspectionFormStructure. And the array looks like:
(lldb) po resources
$2 = 0x1dc6b200 <__NSCFArray 0x1dc6b200>(
"created_at" = "2013-09-30T12:46:52-06:00";
"deleted_at" = "<null>";
id = 140945;
"inspection_form_id" = 31048;
"schedule_id" = "<null>";
"structure_id" = 6539;
"updated_at" = "2013-09-30T12:46:52-06:00";
This goes through the normal import process, but the part that I think is messing up is when it starts importing relationships.
[self MR_setRelationships:relationships forKeysWithObject:objectData withBlock:relationshipBlock];
The first time it is called, it looks good. relationships are the ones for InspectionFormStructure(as expected) and theobjectData` is the one dictionary in the array. So far, so good.
(as expected) and the
But then establishRelationship is called (Line 194).
The relationshipInfo is the NSRelationshipDescription of inspectionForm and the relatedObjectData is just the id (31048).
This calls the block which then calls setRelationshipBlock (side note: these block calls are sometimes hard to follow since there are so many of them). This then goes to:
At this point relatedObject is an empty InspectionForm and the id (myID) isn't set. And I'm not sure how it expected so importValuesForKeysWithObject when localObjectData is just a number. And this is what causes the error. It goes through to MR_performDataImportFromObject:relationshipBlock: then to MR_setRelationships:forKeysWithObject:withBlock: and then fails trying to look up a relationship (lookupKey) on an number (relationshipData).
Am I doing something wrong, or is there something missing in the relationship building?
Again, this only happens occassionally (which I think has to do with my threading issue which I'm trying to figure out).
Any help would be appreciated. Let me know if there is something I can do to help.
Given the age of this issue, and the volume of issues we have to work through, I've decided to close this alongside a number of other older issues.
If you can still replicate the issue under the latest in-development version of MagicalRecord (3.0 at the time of writing), please feel free to re-open and one of @magicalpanda/team-magicalrecord will take another look. Thanks!