Hi,
Let's say you have to-many relationship between two entities: Order <-->> OrderItem. The to-many relationship is called "items". The items to-many is flagged to indicate that the Order owns the destination OrderItem.
Test #1: Create an Order and OrderItem and insert both into an editing context. Then add the item to the order using order.addObjectToBothSidesOfRelationshipWithKey(item, "items"). Then IremoveObjectFromBothSidesOfRelationshipWithKey(item, "items") to remove the item. Then save the editing context.
Result: EOF attempts to save the orphan item. Expected Result: EOF will not attempt to save the orphan item because it was removed from a to-many where the parent owns the destination.
Test #2: Fetch an existing order with one item from the database. Then order.removeObjectFromBothSidesOfRelationshipWithKey(item, "items". Save the editing context.
Result: EOF will delete the orphan item from the database.
Is this how it's supposed to work?
Thanks, Ricardo
|