Exception for missing relatedByAttribute. #263

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+4 −0
Diff settings

Always

Just for now

@@ -236,6 +236,10 @@ + (id) MR_importFromObject:(id)objectData inContext:(NSManagedObjectContext *)co
{
NSAttributeDescription *primaryAttribute = [[self MR_entityDescription] MR_primaryAttributeToRelateBy];
+ NSAssert2(primaryAttribute != nil, @"Importing to the entity '%@' requires User Info key %@ to be set to an attribute name to avoid importing duplicate records.",
+ [[self MR_entityDescription] name],
+ kMagicalRecordImportRelationshipLinkedByKey);
+
id value = [objectData MR_valueForAttribute:primaryAttribute];
NSManagedObject *managedObject = [self MR_findFirstByAttribute:[primaryAttribute name] withValue:value inContext:context];