Core Data Cascade delete rule sometimes doesn't
Core Data Cascade delete rule sometimes doesn't
- Subject: Core Data Cascade delete rule sometimes doesn't
- From: "Doug Knowles" <email@hidden>
- Date: Sun, 10 Feb 2008 23:21:20 -0500
I have an "item" entity in a core data application with a to-many
relationship to a second entity; the relationship's delete rule is set to
"cascade", and the inverse (to-one) relationship's delete rule is set to
nullify.
I implemented a simple action in my application to delete a selected item,
which invokes a "delete" method on item to do some cleanup before ultimately
invoking deleteObject:self on the managed object context. Everything works
as expected; deleting the item causes the relationship's target objects to
be deleted.
I have just implemented an AppleScript command to delete an item, which
invokes the same "delete" method on item. However, when the operation is
completes, the destination objects are not deleted (although the references
in both directions are cleared). This leaves my store in an invalid state
because the target objects are not deleted and have no value for the inverse
relationship back the item, which is not optional.
I can't figure out any reason why this should behave differently in the two
different circumstances. No exceptions are being thrown, and I've stepped
through the AppleScript deletion and it appears to complete normally.
I have seen this problem in other contexts and coded around it (by deleting
the target objects explicitly) under the assumption that I was doing
something wrong. This is the first case I've encountered where the same
method works in one situation and fails in another.
Any ideas?
TIA,
Doug K;
P.S. I've considered filing a bug report, but I can't isolate this code, and
I know the cascade rule works most of the time, so coding a simple test case
will in all likelihood not expose the apparent bug.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden