Thursday, February 25, 2016

Core Data Join Table Records Not Deleted in Ordered Relationship

Tonester:

I’m having trouble with a core data many-to-many relationship where both side’s delete rules are set to Nullify. I’m finding when I inspect the SQL database there are records left in the join table that should be deleted.

The two tables represent Playlists and Tracks. Playlist deletes don’t cascade to delete each track automatically because each track can be in multiple playlists.

Tonester:

I’ve noticed if you delete the relationship i.e. using removePlaylistTracksObject:, then save, then delete the playlist and track, then save, it works. I would expect the relationship record to be removed when deleting either the playlist or track and a single save. Also if the playlist to tracks is not ordered it works fine.

Marcus Zarra:

Thanks for the test case, that is an actual issue in Core Data. There is nothing in there that you are doing incorrectly. You really need to file a radar on this and I will file one as well.

In the interim you can either stop using ordered relationships (they are a bastardization anyway) or do the double delete.

Previously: Core Data Bugs.

Update (2016-02-25): James O’Leary:

Every year for (x) years I think “I should get rid of my ordering hack”, do research, and find CD’s is still broken :(

1 Comment RSS · Twitter


Two observations:

1. If Marcus Zarra is able to file a radar on this, why does Tonester "really need to file a radar" ? (Are otherwise Apple's crowdsourcing goals not achieved ?)
2. It's interesting to note, that ordered relationships are considered a bastardization now.

Leave a Comment