Hello, again!

Ok, my new problem deals with a very simple object graph that isn't propagating deletes as I expect. Here's the simplified setup:

Entity: Map
has a to-many relationship "rooms" to entity Room -- delete rule Cascade

Entity: Room
has a to-one relationship "map" to entity Map -- delete rule Nullify

These relationships are setup as inverses of each other.

My expectation is that if I delete a map entity, it will also delete all rooms objects it references.

Now here's my test code:

- (void) testMapRoomCascade
{
    NSError *error = nil;

    [self createMapAndRoom1];
    NSArray *allRooms = [map allRooms: &error];
    int nRooms = [allRooms count];
STAssertEquals( 1, nRooms, @"Map should have 1 room after creating map and room." );

    NSArray *allMaps = [map allMaps: &error];
    [map delete: [allMaps objectAtIndex: 0]];

    int nMaps = [[map allMaps: &error] count];
STAssertEquals( 0, nMaps, @"Map should have 0 maps after map deletion." );

    allRooms = [map allRooms: &error];
    nRooms = [allRooms count];
STAssertEquals( 0, nRooms, @"Map should have 0 rooms after map deletion due to cascade delete rule." ); // <--- This is the error, since nRooms is still 1!
}

Why isn't the map deletion cascading and causing the room to be deleted? For what it's worth, I also tried saving the context after the delete to see if I could force it to propagate, but that didn't work either.

Wil

--
Wil Hunt

"Life is the art of drawing sufficient conclusions from insufficient premises."
     -- Samuel Butler


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to