Re: Cascade Delete won't delete Department in Apple Sample Code
Re: Cascade Delete won't delete Department in Apple Sample Code
- Subject: Re: Cascade Delete won't delete Department in Apple Sample Code
- From: Quincey Morris <email@hidden>
- Date: Tue, 23 Jun 2009 00:48:16 -0700
On Jun 22, 2009, at 13:55, Jerry Krinock wrote:
In order to understand another problem, I tried this on this the
inverse relationship in Apple's DepartmentAndEmployees Sample Code
project. That is, in the data model, I selected the Employee -->
Department to-one relationship by selecting the 'department'
relationship in the 'Employee' entity, changed its Delete Rule to
Cascade, added some code to log and -processPendingChanges to the
MyDocument class [2], built, and run.
Running, in a new document, I added an Employee, then deleted it. I
expected that the Department would be deleted also, but it was not.
Now I understand that deleting the Department might wreak havoc in
this particular project, or generate a 'deny' error, but according
to the console log [3] it didn't even try. Can anyone suggest why
not?
I think it boils down to this:
The delete rules are really about ownership. Department->Employee
ownership is clear: *the* department owns each of its employees. But
Employee->Department ownership isn't well defined. (If two employees
"own" the same department, who gets to decide when to delete the
department?) Therefore, apparently, the problematic cases (Nullify and
Cascade) are just ignored -- beyond the necessary step of removing the
Employee from the Department's set of related Employees.
So for Cascade it's not so much that Core Data failed to deliver on a
promise to delete the Department, but rather that it never really
promised.
The Nullify case is wrong, too -- nothing in the Department actually
gets set to nil -- but the removal of the pointer from the
relationship set is near enough to fulfillment of a Nullify promise
that it doesn't seem like it didn't work.
_______________________________________________
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