mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-04-22 12:55:44 +00:00
* EOAccess/EODatabaseContext.m
recordUpdateForObject: changes: more checks, call coordinator's forwardUpdateForObject:changes: recordInsertForObject: raise exception on inconsistency recordDeleteForObject: raise exception on inconsistency commitChanges: remove NSLog git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@30722 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6294a2b46f
commit
54ec6f178e
2 changed files with 44 additions and 38 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2010-06-14 David Wetzel <dave@turbocat.de>
|
||||
* EOAccess/EODatabaseContext.m
|
||||
recordUpdateForObject: changes:
|
||||
more checks, call coordinator's
|
||||
forwardUpdateForObject:changes:
|
||||
recordInsertForObject:
|
||||
raise exception on inconsistency
|
||||
recordDeleteForObject:
|
||||
raise exception on inconsistency
|
||||
commitChanges:
|
||||
remove NSLog
|
||||
|
||||
2010-06-11 David Wetzel <dave@turbocat.de>
|
||||
* EOAccess/EODatabase.m
|
||||
* EOAccess/EODatabase.h
|
||||
|
|
|
@ -2848,32 +2848,25 @@ but not owned by this context to the coordinator.
|
|||
- (void)recordUpdateForObject: (id)object
|
||||
changes: (NSDictionary *)changes
|
||||
{
|
||||
//OK
|
||||
EODatabaseOperation *dbOpe = nil;
|
||||
|
||||
|
||||
|
||||
NSAssert(object, @"No object");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[self _assertValidStateWithSelector:
|
||||
@selector(recordUpdateForObject:changes:)];
|
||||
|
||||
@selector(recordUpdateForObject:changes:)];
|
||||
|
||||
dbOpe = [self databaseOperationForObject: object];
|
||||
|
||||
|
||||
[dbOpe setDatabaseOperator:EODatabaseUpdateOperator];
|
||||
|
||||
|
||||
if ([changes count])
|
||||
|
||||
if (dbOpe) {
|
||||
[dbOpe setDatabaseOperator:EODatabaseUpdateOperator];
|
||||
if ((changes) && ([changes count]))
|
||||
{
|
||||
[[dbOpe newRow] addEntriesFromDictionary: changes];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
[[self coordinator] forwardUpdateForObject:object
|
||||
changes:changes];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)recordInsertForObject: (id)object
|
||||
|
@ -2881,20 +2874,18 @@ but not owned by this context to the coordinator.
|
|||
NSDictionary *snapshot = nil;
|
||||
EODatabaseOperation *dbOpe = nil;
|
||||
|
||||
|
||||
|
||||
dbOpe = [self databaseOperationForObject: object];
|
||||
|
||||
|
||||
[dbOpe setDatabaseOperator: EODatabaseInsertOperator];
|
||||
|
||||
snapshot = [dbOpe dbSnapshot];
|
||||
|
||||
snapshot = [dbOpe dbSnapshot]; //TODO: sowhat
|
||||
NSDebugMLLog(@"EODatabaseContext", @"object=%p snapshot=%@",
|
||||
object, snapshot);
|
||||
|
||||
//call snapshot count
|
||||
|
||||
if ([snapshot count] != 0)
|
||||
{
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s found a snapshot for EO with Global ID: %@ that has been inserted into %@."
|
||||
@"Cannot insert an object that is already in the database",
|
||||
__PRETTY_FUNCTION__, [dbOpe globalID], _editingContext];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -2902,16 +2893,20 @@ but not owned by this context to the coordinator.
|
|||
{
|
||||
NSDictionary *snapshot = nil;
|
||||
EODatabaseOperation *dbOpe = nil;
|
||||
|
||||
|
||||
|
||||
|
||||
dbOpe = [self databaseOperationForObject: object];
|
||||
|
||||
|
||||
|
||||
[dbOpe setDatabaseOperator: EODatabaseDeleteOperator];
|
||||
snapshot = [dbOpe dbSnapshot]; //TODO: sowhat
|
||||
|
||||
|
||||
|
||||
snapshot = [dbOpe dbSnapshot];
|
||||
|
||||
if (([snapshot count] == 0))
|
||||
{
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s failed to find a snapshot for EO with Global ID: %@ that has been deleted from %@."
|
||||
@"Cannot delete an object that has not been fetched from the database",
|
||||
__PRETTY_FUNCTION__, [dbOpe globalID], _editingContext];
|
||||
}
|
||||
}
|
||||
|
||||
/** Constructs EOAdaptorOperations for all EODatabaseOperations constructed in
|
||||
|
@ -3219,7 +3214,6 @@ Raises an exception is the adaptor is unable to perform the operations.
|
|||
newRowValues = [dbOpe rowDiffsForAttributes: [entity _classPropertyAttributes]];
|
||||
break;
|
||||
default:
|
||||
NSLog(@"%s databaseOperator %d unknown", __PRETTY_FUNCTION__, databaseOperator);
|
||||
break;
|
||||
}
|
||||
id object = [dbOpe object];
|
||||
|
|
Loading…
Reference in a new issue