magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.8k stars 1.79k forks source link

Relationship import overwrites properties of related objects #1152

Open pronebird opened 8 years ago

pronebird commented 8 years ago

I have a Keyword entity that points to Category via one-to-one relationship and inverse relationship that is to-many.

Keyword.category (one) <-> Category.keywords (many)

To wire up both during seed data import, I've added Category.identifier and JSON payload comes with:

{ category: "some-category-identifier", ... }

Keyword.category relationship's userInfo is set to following:

mappedKeyName: category
relatedByAttribute: identifier

Which seems to work and related object (category) is being pulled from CoreData, but then MagicalRecord attempts to update the property of related object.

Is there any concise way to simply wire up relationships between objects without doing anything with related objects?

Essentially this part of import does some non-sense:

https://github.com/magicalpanda/MagicalRecord/blob/master/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m#L289

While this seems a no-op I am not sure how this will work in other cases. In my case it overwrites a string with identifier on Category entity with apparently the same value it used to find it in the first place....