Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Minor fixes for importing related entities #600

Closed
wants to merge 2 commits into from

2 participants

@KentMcCullough

No description provided.

@tonyarnold
Owner

Hi Kent — do you have a specific example where this was failing? I'd like to put together a test for what this fixes.

@tonyarnold tonyarnold was assigned
@KentMcCullough

The first commit fixes importing a child entity as a parent entity. e.g. User entity has Instructor and Student sub entities, it will allow you to import either when the relationship is to the User entity.

The second uses the mappedKeyName value of the userInfo dictionary when importing a relationship as opposed to a specific property.

@tonyarnold
Owner

These appear to have been fixed in 7e4c076 and 13cbe84. Thanks!

@tonyarnold tonyarnold closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  MagicalRecord/Categories/DataImport/NSObject+MagicalDataImport.m
@@ -61,7 +61,7 @@ - (NSString *) MR_lookupKeyForRelationship:(NSRelationshipDescription *)relation
NSString *primaryKeyName = [relationshipInfo MR_primaryKey];
NSAttributeDescription *primaryKeyAttribute = [destinationEntity MR_attributeDescriptionForName:primaryKeyName];
- NSString *lookupKey = [[primaryKeyAttribute userInfo] valueForKey:kMagicalRecordImportAttributeKeyMapKey] ? :[primaryKeyAttribute name];
+ NSString *lookupKey = [self MR_lookupKeyForAttribute:primaryKeyAttribute] ?: [primaryKeyAttribute name];
return lookupKey;
}
View
4 MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m
@@ -118,8 +118,8 @@ - (NSManagedObject *) MR_findObjectForRelationship:(NSRelationshipDescription *)
- (void) MR_addObject:(NSManagedObject *)relatedObject forRelationship:(NSRelationshipDescription *)relationshipInfo
{
NSAssert2(relatedObject != nil, @"Cannot add nil to %@ for attribute %@", NSStringFromClass([self class]), [relationshipInfo name]);
- NSAssert2([relatedObject entity] == [relationshipInfo destinationEntity], @"related object entity %@ not same as destination entity %@", [relatedObject entity], [relationshipInfo destinationEntity]);
-
+ NSAssert2([[relatedObject entity] isKindOfEntity:[relationshipInfo destinationEntity]], @"related object entity %@ not same as destination entity %@", [relatedObject entity], [relationshipInfo destinationEntity]);
+
//add related object to set
NSString *addRelationMessageFormat = @"set%@:";
id relationshipSource = self;
Something went wrong with that request. Please try again.