mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-21 02:20:55 +00:00
* EOAccess/EODatabaseOperation.h
add comment * EOAccess/EODatabaseContext.h -lockingNonQualifiableAttributes return NSArray, not id -handleDroppedConnection -commitChanges remove unsed variables -createAdaptorOperationsForDatabaseOperation:attributes: rewrite -lockingNonQualifiableAttributes fix return NSArray, not id git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@30910 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c00b1ebc37
commit
4d27bfcdab
5 changed files with 203 additions and 350 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
||||||
|
2010-07-01 David Wetzel <dave@turbocat.de>
|
||||||
|
* EOAccess/EODatabaseOperation.h
|
||||||
|
add comment
|
||||||
|
* EOAccess/EODatabaseContext.h
|
||||||
|
-lockingNonQualifiableAttributes
|
||||||
|
return NSArray, not id
|
||||||
|
-handleDroppedConnection
|
||||||
|
-commitChanges
|
||||||
|
remove unsed variables
|
||||||
|
-createAdaptorOperationsForDatabaseOperation:attributes:
|
||||||
|
rewrite
|
||||||
|
-lockingNonQualifiableAttributes
|
||||||
|
fix
|
||||||
|
return NSArray, not id
|
||||||
|
|
||||||
|
|
||||||
2010-06-29 David Wetzel <dave@turbocat.de>
|
2010-06-29 David Wetzel <dave@turbocat.de>
|
||||||
* EOAccess/EOModel.m
|
* EOAccess/EOModel.m
|
||||||
-addEntity:
|
-addEntity:
|
||||||
|
|
|
@ -582,8 +582,6 @@ prepareInsertExpressionWithRow:changedValues
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
count=[adaptorOperations count];
|
count=[adaptorOperations count];
|
||||||
|
|
||||||
for(i = 0; i < count; i++)
|
for(i = 0; i < count; i++)
|
||||||
|
|
|
@ -266,7 +266,7 @@ It's invoked after prepareForSaveWithCoordinator:editingContext: and before owns
|
||||||
- (NSArray *)entityNameOrderingArrayForEntities: (NSArray *)entities;
|
- (NSArray *)entityNameOrderingArrayForEntities: (NSArray *)entities;
|
||||||
|
|
||||||
- (BOOL)isValidQualifierTypeForAttribute: (EOAttribute *)attribute;
|
- (BOOL)isValidQualifierTypeForAttribute: (EOAttribute *)attribute;
|
||||||
- (id)lockingNonQualifiableAttributes: (NSArray *)attributes;
|
- (NSArray *)lockingNonQualifiableAttributes: (NSArray *)attributes;
|
||||||
- (NSArray *)lockingAttributesForAttributes: (NSArray *)attributes
|
- (NSArray *)lockingAttributesForAttributes: (NSArray *)attributes
|
||||||
entity: (EOEntity *)entity;
|
entity: (EOEntity *)entity;
|
||||||
- (NSArray *)primaryKeyAttributesForAttributes: (NSArray *)attributes
|
- (NSArray *)primaryKeyAttributesForAttributes: (NSArray *)attributes
|
||||||
|
|
|
@ -612,8 +612,6 @@ May raise an exception if transaction has began or if you want pessimistic lock
|
||||||
|
|
||||||
- (void)handleDroppedConnection
|
- (void)handleDroppedConnection
|
||||||
{
|
{
|
||||||
NSUInteger i;
|
|
||||||
|
|
||||||
DESTROY(_adaptorContext);
|
DESTROY(_adaptorContext);
|
||||||
|
|
||||||
DESTROY(_registeredChannels);
|
DESTROY(_registeredChannels);
|
||||||
|
@ -3164,7 +3162,6 @@ Raises an exception is the adaptor is unable to perform the operations.
|
||||||
NSMutableArray *updatedObjects = [NSMutableArray array];
|
NSMutableArray *updatedObjects = [NSMutableArray array];
|
||||||
NSMutableDictionary *gidChangedUserInfo = nil;
|
NSMutableDictionary *gidChangedUserInfo = nil;
|
||||||
NSMutableDictionary *gidChangedUserInfo2 = nil;
|
NSMutableDictionary *gidChangedUserInfo2 = nil;
|
||||||
NSEnumerator * dbOperationsEnumer = nil;
|
|
||||||
|
|
||||||
[self _assertValidStateWithSelector: @selector(commitChanges)];
|
[self _assertValidStateWithSelector: @selector(commitChanges)];
|
||||||
|
|
||||||
|
@ -4178,327 +4175,176 @@ Raises an exception is the adaptor is unable to perform the operations.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) createAdaptorOperationsForDatabaseOperation: (EODatabaseOperation*)dbOpe
|
- (void) createAdaptorOperationsForDatabaseOperation: (EODatabaseOperation*)dbOpe
|
||||||
attributes: (NSArray*)attributes
|
attributes: (NSArray*)attributes
|
||||||
{
|
{
|
||||||
//NEAR OK
|
EOEntity * entity = nil;
|
||||||
BOOL isSomethingTodo = YES;
|
|
||||||
EOEntity *entity = nil;
|
|
||||||
EODatabaseOperator dbOperator = EODatabaseNothingOperator;
|
EODatabaseOperator dbOperator = EODatabaseNothingOperator;
|
||||||
NSDictionary *changedValues = nil;
|
NSDictionary * changedValues = nil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSAssert(dbOpe, @"No operation");
|
NSAssert(dbOpe, @"No operation");
|
||||||
|
|
||||||
entity = [dbOpe entity]; //OK
|
entity = [dbOpe entity]; //OK
|
||||||
dbOperator = [dbOpe databaseOperator]; //OK
|
dbOperator = [dbOpe databaseOperator]; //OK
|
||||||
|
EOAdaptorOperation * lockOperation = nil;
|
||||||
|
NSDictionary * dbSnapshot = nil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch (dbOperator)
|
|
||||||
{
|
|
||||||
case EODatabaseUpdateOperator:
|
|
||||||
{
|
|
||||||
changedValues = [dbOpe rowDiffsForAttributes:attributes];
|
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext", @"changedValues %p=%@",
|
|
||||||
changedValues, changedValues);
|
|
||||||
|
|
||||||
if ([changedValues count] == 0)
|
|
||||||
isSomethingTodo = NO;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EODatabaseInsertOperator:
|
|
||||||
{
|
|
||||||
changedValues = [dbOpe newRow]; //OK
|
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext", @"changedValues %p=%@",
|
|
||||||
changedValues, changedValues);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EODatabaseDeleteOperator:
|
|
||||||
{
|
|
||||||
isSomethingTodo = YES;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EODatabaseNothingOperator:
|
|
||||||
{
|
|
||||||
//Nothing!
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
NSEmitTODO();
|
|
||||||
// [self notImplemented:_cmd]; //TODO
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSomethingTodo)
|
|
||||||
{
|
|
||||||
EOAdaptorOperation *adaptorOpe = nil;
|
|
||||||
NSString *procedureOpeName = nil;
|
|
||||||
EOAdaptorOperator adaptorOperator = EOAdaptorUndefinedOperator;
|
|
||||||
EOStoredProcedure *storedProcedure = nil;
|
|
||||||
|
|
||||||
NSDictionary *valuesToWrite = nil;
|
|
||||||
EOQualifier *lockingQualifier = nil;
|
EOQualifier *lockingQualifier = nil;
|
||||||
|
|
||||||
switch (dbOperator)
|
switch (dbOperator)
|
||||||
{
|
{
|
||||||
case EODatabaseUpdateOperator:
|
case EODatabaseNothingOperator:
|
||||||
case EODatabaseDeleteOperator:
|
break;
|
||||||
|
case EODatabaseInsertOperator:
|
||||||
{
|
{
|
||||||
NSArray *pkAttributes;
|
EOAdaptorOperation * insertOp = nil;
|
||||||
NSArray *lockingAttributes;
|
EOStoredProcedure * insertProc = nil;
|
||||||
NSDictionary *dbSnapshot;
|
NSDictionary * writeAttrValues = nil;
|
||||||
|
|
||||||
pkAttributes = [self primaryKeyAttributesForAttributes: attributes
|
changedValues = [dbOpe newRow];
|
||||||
entity: entity];
|
writeAttrValues = [self valuesToWriteForAttributes:attributes
|
||||||
lockingAttributes = [self lockingAttributesForAttributes:
|
entity:entity
|
||||||
attributes
|
changedValues:changedValues];
|
||||||
entity: entity];
|
if ([writeAttrValues count] < 1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
insertOp = [EOAdaptorOperation adaptorOperationWithEntity:entity];
|
||||||
|
insertProc = [entity storedProcedureForOperation:EOInsertProcedureOperation];
|
||||||
|
|
||||||
|
if (insertProc)
|
||||||
|
{
|
||||||
|
[insertOp setAdaptorOperator:EOAdaptorStoredProcedureOperator];
|
||||||
|
[insertOp setStoredProcedure:insertProc];
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
[insertOp setAdaptorOperator:EOAdaptorInsertOperator];
|
||||||
|
}
|
||||||
|
[insertOp setChangedValues:writeAttrValues];
|
||||||
|
[dbOpe addAdaptorOperation:insertOp];
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EODatabaseUpdateOperator:
|
||||||
|
{
|
||||||
|
NSArray * lockNonQualAttrs = nil;
|
||||||
|
NSArray * pkAttributes = nil;
|
||||||
|
NSArray * lockingAttributes = nil;
|
||||||
|
NSUInteger changeCount, lockNonQualCount, lockAttrCount;
|
||||||
|
|
||||||
|
changedValues = [dbOpe rowDiffsForAttributes:attributes];
|
||||||
|
lockNonQualAttrs = [self lockingNonQualifiableAttributes:attributes];
|
||||||
|
lockingAttributes = [self lockingAttributesForAttributes:attributes
|
||||||
|
entity:entity];
|
||||||
|
|
||||||
|
changeCount = [changedValues count];
|
||||||
|
lockNonQualCount = [lockNonQualAttrs count];
|
||||||
|
lockAttrCount = [lockingAttributes count];
|
||||||
|
|
||||||
|
// test if we have anything to do
|
||||||
|
|
||||||
|
if (((changeCount == 0)) && ((lockNonQualCount == 0)) && ((lockAttrCount == 0))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pkAttributes = [self primaryKeyAttributesForAttributes:attributes
|
||||||
|
entity:entity];
|
||||||
|
|
||||||
dbSnapshot = [dbOpe dbSnapshot];
|
dbSnapshot = [dbOpe dbSnapshot];
|
||||||
|
|
||||||
lockingQualifier = [self qualifierForLockingAttributes:
|
lockingQualifier = [self qualifierForLockingAttributes:lockingAttributes
|
||||||
lockingAttributes
|
primaryKeyAttributes:pkAttributes
|
||||||
primaryKeyAttributes: pkAttributes
|
entity:entity
|
||||||
entity: entity
|
snapshot:dbSnapshot];
|
||||||
snapshot: dbSnapshot];
|
|
||||||
|
|
||||||
NSEmitTODO();
|
if (((changeCount == 0)) || (lockNonQualCount > 0))
|
||||||
|
|
||||||
//TODO=self lockingNonQualifiableAttributes:##### ret nil
|
|
||||||
NSDebugMLLog(@"EODatabaseContext", @"lockingQualifier=%@",
|
|
||||||
lockingQualifier);
|
|
||||||
|
|
||||||
/*MIRKO for UPDATE:
|
|
||||||
//TODO-NOW
|
|
||||||
{
|
{
|
||||||
if ([self isObjectLockedWithGlobalID:gid] == NO)
|
lockOperation = [EOAdaptorOperation adaptorOperationWithEntity:entity];
|
||||||
{
|
|
||||||
EOAdaptorOperation *lockOperation;
|
|
||||||
EOQualifier *qualifier;
|
|
||||||
EOAttribute *attribute;
|
|
||||||
NSEnumerator *attrsEnum;
|
|
||||||
NSArray *attrsUsedForLocking, *primaryKeyAttributes;
|
|
||||||
NSMutableDictionary *qualifierSnapshot, *lockSnapshot;
|
|
||||||
NSMutableArray *lockAttributes;
|
|
||||||
|
|
||||||
lockOperation = [EOAdaptorOperation adaptorOperationWithEntity:
|
|
||||||
entity];
|
|
||||||
|
|
||||||
attrsUsedForLocking = [entity attributesUsedForLocking];
|
|
||||||
primaryKeyAttributes = [entity primaryKeyAttributes];
|
|
||||||
|
|
||||||
qualifierSnapshot = [NSMutableDictionary
|
|
||||||
dictionaryWithCapacity:16];
|
|
||||||
lockSnapshot = [NSMutableDictionary dictionaryWithCapacity:8];
|
|
||||||
lockAttributes = [NSMutableArray arrayWithCapacity:8];
|
|
||||||
|
|
||||||
attrsEnum = [primaryKeyAttributes objectEnumerator];
|
|
||||||
while ((attribute = [attrsEnum nextObject]))
|
|
||||||
{
|
|
||||||
NSString *name = [attribute name];
|
|
||||||
|
|
||||||
[lockSnapshot setObject:[snapshot objectForKey:name]
|
|
||||||
forKey:name];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
attrsEnum = [attrsUsedForLocking objectEnumerator];
|
|
||||||
while ((attribute = [attrsEnum nextObject]))
|
|
||||||
{
|
|
||||||
NSString *name = [attribute name];
|
|
||||||
|
|
||||||
if ([primaryKeyAttributes containsObject:attribute] == NO)
|
|
||||||
{
|
|
||||||
if ([attribute adaptorValueType] == EOAdaptorBytesType)
|
|
||||||
{
|
|
||||||
[lockAttributes addObject:attribute];
|
|
||||||
[lockSnapshot setObject:[snapshot
|
|
||||||
objectForKey:name]
|
|
||||||
forKey:name];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
[qualifierSnapshot setObject:[snapshot
|
|
||||||
objectForKey:name]
|
|
||||||
forKey:name];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
qualifier = AUTORELEASE([[EOAndQualifier alloc]
|
|
||||||
initWithQualifiers:
|
|
||||||
[entity qualifierForPrimaryKey:
|
|
||||||
[entity primaryKeyForGlobalID:
|
|
||||||
(EOKeyGlobalID *)gid]],
|
|
||||||
[EOQualifier qualifierToMatchAllValues:
|
|
||||||
qualifierSnapshot],
|
|
||||||
nil]);
|
|
||||||
|
|
||||||
if ([lockAttributes count] == 0)
|
|
||||||
lockAttributes = nil;
|
|
||||||
if ([lockSnapshot count] == 0)
|
|
||||||
lockSnapshot = nil;
|
|
||||||
|
|
||||||
[lockOperation setAdaptorOperator:EOAdaptorLockOperator];
|
[lockOperation setAdaptorOperator:EOAdaptorLockOperator];
|
||||||
[lockOperation setQualifier:qualifier];
|
[lockOperation setQualifier:lockingQualifier];
|
||||||
[lockOperation setAttributes:lockAttributes];
|
[lockOperation setChangedValues:dbSnapshot];
|
||||||
[lockOperation setChangedValues:lockSnapshot];
|
|
||||||
|
|
||||||
|
if (lockNonQualCount > 0)
|
||||||
[op addAdaptorOperation:lockOperation];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EODatabaseInsertOperator:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EODatabaseNothingOperator:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
adaptorOpe = [EOAdaptorOperation adaptorOperationWithEntity: entity];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch (dbOperator)
|
|
||||||
{
|
{
|
||||||
case EODatabaseInsertOperator:
|
[lockOperation setAttributes:lockNonQualAttrs];
|
||||||
procedureOpeName = @"EOInsertProcedure";
|
} else {
|
||||||
adaptorOperator = EOAdaptorInsertOperator;
|
[lockOperation setAttributes:pkAttributes];
|
||||||
|
}
|
||||||
|
[dbOpe addAdaptorOperation:lockOperation];
|
||||||
|
}
|
||||||
|
if (changeCount > 0)
|
||||||
|
{
|
||||||
|
NSDictionary * writeAttrValues = nil;
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext", @"changedValues %p=%@",
|
writeAttrValues = [self valuesToWriteForAttributes:attributes
|
||||||
changedValues, changedValues);
|
entity:entity
|
||||||
|
changedValues:changedValues];
|
||||||
|
if ([writeAttrValues count] > 0)
|
||||||
|
{
|
||||||
|
EOAdaptorOperation * updateOperation = nil;
|
||||||
|
|
||||||
valuesToWrite = [self valuesToWriteForAttributes: attributes
|
updateOperation = [EOAdaptorOperation adaptorOperationWithEntity:entity];
|
||||||
entity: entity
|
[updateOperation setAdaptorOperator:EOAdaptorUpdateOperator];
|
||||||
changedValues: changedValues];
|
[updateOperation setChangedValues:writeAttrValues];
|
||||||
|
[updateOperation setQualifier:lockingQualifier];
|
||||||
|
[dbOpe addAdaptorOperation:updateOperation];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EODatabaseUpdateOperator:
|
|
||||||
procedureOpeName = @"EOUpdateProcedure";
|
|
||||||
adaptorOperator = EOAdaptorUpdateOperator;
|
|
||||||
valuesToWrite = [self valuesToWriteForAttributes: attributes
|
|
||||||
entity: entity
|
|
||||||
changedValues: changedValues];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EODatabaseDeleteOperator:
|
case EODatabaseDeleteOperator:
|
||||||
procedureOpeName = @"EODeleteProcedure";
|
|
||||||
adaptorOperator = EOAdaptorDeleteOperator;
|
|
||||||
/*
|
|
||||||
MIRKO
|
|
||||||
NSMutableArray *newKeys = AUTORELEASE([[NSMutableArray alloc]
|
|
||||||
initWithCapacity:count]);
|
|
||||||
NSMutableArray *newVals = AUTORELEASE([[NSMutableArray alloc]
|
|
||||||
initWithCapacity:count]);
|
|
||||||
|
|
||||||
if ([entity isReadOnly] == YES)
|
|
||||||
{
|
{
|
||||||
[NSException raise:NSInvalidArgumentException format:@"%@ -- %@ 0x%x: cannot delete object for readonly entity %@", NSStringFromSelector(_cmd), NSStringFromClass([self class]), self, [entity name]];
|
NSArray * pkAttributes = nil;
|
||||||
}
|
NSArray * lockingAttributes = nil;
|
||||||
|
NSArray * lockNonQualAttrs = nil;
|
||||||
|
EOAdaptorOperation * deleteOp = nil;
|
||||||
|
EOStoredProcedure * deleteProc = nil;
|
||||||
|
|
||||||
[aOp setAdaptorOperator:EOAdaptorDeleteOperator];
|
pkAttributes = [self primaryKeyAttributesForAttributes:attributes
|
||||||
|
entity:entity];
|
||||||
|
|
||||||
count = [primaryKeys count];
|
lockingAttributes = [self lockingAttributesForAttributes:attributes
|
||||||
for (i = 0; i < count; i++)
|
entity:entity];
|
||||||
|
|
||||||
|
dbSnapshot = [dbOpe dbSnapshot];
|
||||||
|
|
||||||
|
lockingQualifier = [self qualifierForLockingAttributes:lockingAttributes
|
||||||
|
primaryKeyAttributes:pkAttributes
|
||||||
|
entity:entity
|
||||||
|
snapshot:dbSnapshot];
|
||||||
|
|
||||||
|
lockNonQualAttrs = [self lockingNonQualifiableAttributes:attributes];
|
||||||
|
|
||||||
|
if ([lockNonQualAttrs count] > 0)
|
||||||
{
|
{
|
||||||
EOAttribute *attribute = [primaryKeys objectAtIndex:i];
|
lockOperation = [EOAdaptorOperation adaptorOperationWithEntity:entity];
|
||||||
NSString *key = [attribute name];
|
[lockOperation setAdaptorOperator:EOAdaptorLockOperator]; /* 0 in EOF */
|
||||||
id val;
|
[lockOperation setQualifier:lockingQualifier];
|
||||||
if ([attribute isFlattened] == NO)
|
[lockOperation setAttributes:lockNonQualAttrs];
|
||||||
|
[lockOperation setChangedValues:dbSnapshot];
|
||||||
|
[dbOpe addAdaptorOperation:lockOperation];
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteOp = [EOAdaptorOperation adaptorOperationWithEntity:entity];
|
||||||
|
deleteProc = [entity storedProcedureForOperation:EODeleteProcedureOperation];
|
||||||
|
|
||||||
|
if (deleteProc)
|
||||||
{
|
{
|
||||||
// Turbocat
|
[deleteOp setAdaptorOperator:EOAdaptorStoredProcedureOperator]; /* 4 */
|
||||||
//val = [object storedValueForKey:key];
|
[deleteOp setStoredProcedure:deleteProc];
|
||||||
if (currentSnapshot) {
|
[deleteOp setChangedValues:dbSnapshot];
|
||||||
val = [currentSnapshot objectForKey:key];
|
} else {
|
||||||
|
[deleteOp setAdaptorOperator:EOAdaptorDeleteOperator]; /* 3 */
|
||||||
|
[deleteOp setQualifier:lockingQualifier];
|
||||||
}
|
}
|
||||||
|
[dbOpe addAdaptorOperation:deleteOp];
|
||||||
|
|
||||||
if (!val) {
|
|
||||||
[NSException raise:NSInvalidArgumentException format:@"%@ -- %@ 0x%x: cannot delete object (snapshot) '%@' for unkown primarykey value '%@'", NSStringFromSelector(_cmd), NSStringFromClass([self class]), self, currentSnapshot, key];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val == nil)
|
|
||||||
val = GDL2_EONull;
|
|
||||||
|
|
||||||
[newKeys addObject:key];
|
|
||||||
[newVals addObject:val];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
row = [NSDictionary dictionaryWithObjects:newVals
|
|
||||||
forKeys:newKeys];
|
|
||||||
|
|
||||||
[aOp setQualifier:[entity qualifierForPrimaryKey:[op newRow]]];
|
|
||||||
|
|
||||||
==>NO? in _commitTransaction [self forgetSnapshotForGlobalID:[op globalID]];
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EODatabaseNothingOperator:
|
|
||||||
NSDebugMLLog(@"EODatabaseContext",
|
|
||||||
@"Db Ope %@ for Nothing !!!", dbOpe);
|
|
||||||
//Nothing?
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
NSEmitTODO();
|
|
||||||
[self notImplemented: _cmd]; //TODO
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// only for insert ??
|
|
||||||
storedProcedure = [entity storedProcedureForOperation: procedureOpeName];
|
|
||||||
if (storedProcedure)
|
|
||||||
{
|
|
||||||
adaptorOperator = EOAdaptorStoredProcedureOperator;
|
|
||||||
NSEmitTODO();
|
|
||||||
[self notImplemented: _cmd]; //TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext", @"adaptorOperator=%d",
|
|
||||||
adaptorOperator);
|
|
||||||
|
|
||||||
|
|
||||||
if (adaptorOpe)
|
|
||||||
{
|
|
||||||
[adaptorOpe setAdaptorOperator: adaptorOperator];
|
|
||||||
|
|
||||||
|
|
||||||
if (valuesToWrite)
|
|
||||||
[adaptorOpe setChangedValues: valuesToWrite];
|
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext", @"lockingQualifier=%@",
|
|
||||||
lockingQualifier);
|
|
||||||
|
|
||||||
if (lockingQualifier)
|
|
||||||
[adaptorOpe setQualifier: lockingQualifier];
|
|
||||||
|
|
||||||
[dbOpe addAdaptorOperation: adaptorOpe];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) createAdaptorOperationsForDatabaseOperation: (EODatabaseOperation*)dbOpe
|
- (void) createAdaptorOperationsForDatabaseOperation: (EODatabaseOperation*)dbOpe
|
||||||
|
@ -4817,47 +4663,42 @@ Raises an exception is the adaptor is unable to perform the operations.
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) lockingNonQualifiableAttributes: (NSArray*)attributes
|
- (NSArray*) lockingNonQualifiableAttributes: (NSArray*)attributes
|
||||||
{
|
{
|
||||||
//TODO finish
|
NSMutableArray * lockingAttrs = nil;
|
||||||
EOEntity *entity = nil;
|
NSArray * attributesUsedForLocking = nil;
|
||||||
NSArray *attributesUsedForLocking = nil;
|
NSUInteger i = [attributes count];
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
count = [attributes count];
|
for (; i > 0; i--)
|
||||||
|
|
||||||
if (count>0)
|
|
||||||
{
|
{
|
||||||
IMP oaiIMP=[attributes methodForSelector: @selector(objectAtIndex:)];
|
EOAttribute * attr = [attributes objectAtIndex:i-1];
|
||||||
int i=0;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
if (!attributesUsedForLocking)
|
||||||
{
|
{
|
||||||
id attribute = GDL2_ObjectAtIndexWithImp(attributes,oaiIMP,i);
|
attributesUsedForLocking = [[attr entity] attributesUsedForLocking];
|
||||||
|
|
||||||
if (!entity)
|
|
||||||
{
|
|
||||||
entity = [attribute entity];
|
|
||||||
attributesUsedForLocking = [entity attributesUsedForLocking];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![self isValidQualifierTypeForAttribute: attribute])
|
if ([self isValidQualifierTypeForAttribute:attr] ||
|
||||||
|
(![attributesUsedForLocking containsObject:attr]))
|
||||||
{
|
{
|
||||||
NSEmitTODO();
|
continue;
|
||||||
// [self notImplemented:_cmd]; //TODO
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
NSEmitTODO();
|
|
||||||
//Nothing ??
|
|
||||||
// [self notImplemented:_cmd]; //TODO ??
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return nil;//??
|
if (!lockingAttrs)
|
||||||
|
{
|
||||||
|
lockingAttrs = [NSMutableArray array];
|
||||||
|
}
|
||||||
|
[lockingAttrs addObject:attr];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lockingAttrs) {
|
||||||
|
lockingAttrs = [NSArray array];
|
||||||
|
}
|
||||||
|
|
||||||
|
return lockingAttrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (NSArray*) lockingAttributesForAttributes: (NSArray*)attributes
|
- (NSArray*) lockingAttributesForAttributes: (NSArray*)attributes
|
||||||
entity: (EOEntity*)entity
|
entity: (EOEntity*)entity
|
||||||
{
|
{
|
||||||
|
@ -5089,12 +4930,6 @@ Raises an exception is the adaptor is unable to perform the operations.
|
||||||
NSMutableDictionary *valuesToWrite = [NSMutableDictionary dictionary];
|
NSMutableDictionary *valuesToWrite = [NSMutableDictionary dictionary];
|
||||||
BOOL isReadOnlyEntity = NO;
|
BOOL isReadOnlyEntity = NO;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
isReadOnlyEntity = [entity isReadOnly];
|
isReadOnlyEntity = [entity isReadOnly];
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext", @"isReadOnlyEntity=%s",
|
NSDebugMLLog(@"EODatabaseContext", @"isReadOnlyEntity=%s",
|
||||||
|
|
|
@ -46,6 +46,10 @@
|
||||||
@class EOQualifier;
|
@class EOQualifier;
|
||||||
@class EOGlobalID;
|
@class EOGlobalID;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EOF does not have EOAdaptorUndefinedOperator
|
||||||
|
* so be careful with counting.
|
||||||
|
*/
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EOAdaptorUndefinedOperator = 0,
|
EOAdaptorUndefinedOperator = 0,
|
||||||
|
|
Loading…
Reference in a new issue