[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Controlling the order of deletions and insertions in regards to the Editing Contexte
Here is a code snippet that will do deletes first. It can be used by setting
the delegate on the database context object.
// Order the delete operations first (EODatabaseDeleteOperator).
- (NSArray *)databaseContext:(EODatabaseContext *)context
willOrderAdaptorOperationsFromDatabaseOperations:(NSArray *)databaseOps {
NSMutableArray *sortedOps = [NSMutableArray array];
NSMutableArray *addedOps = [NSMutableArray array];
NSEnumerator *enumerator = [databaseOps objectEnumerator];
EODatabaseOperation *op;
// first add the delete operations
while (op = [enumerator nextObject]) {
if ([op databaseOperator] == EODatabaseDeleteOperator) {
[sortedOps addObjectsFromArray:[op adaptorOperations]];
[addedOps addObject:op];
}
}
// now add the rest...
enumerator = [databaseOps objectEnumerator];
while (op = [enumerator nextObject]) {
if (![addedOps containsObject:op])
[sortedOps addObjectsFromArray:[op adaptorOperations]];
}
return sortedOps;
}
> -----Original Message-----
> From: IDfusion [mailto:uunet!id-fusion.com!solutions]
> Sent: Tuesday, January 05, 1999 10:48 AM
> To: Multiple recipients of list
> Subject: Controlling the order of deletions and insertions in
> regards to
> the Editing Contexte
>
>
> While running my application I make insertions and deletions
> which makes
> changes to the Editing Contexte. I then save the changes to
> the Editing
> Contexte. When I perform the save to the Editing Contexte I
> look at the
> SQL generated. First all the inserts are called and then all the
> deletes. Why do the insert operations get executed first? Is
> there a way
> to change this? I guess part of my question could be answered
> if someone
> could explain the process that the Editing Contexte takes
> when updating
> the database.
>
> Rob
>