2002-11-26 Manuel Guesdon <mguesdon@orange-concept.com>

* EOAccess/EOEntity.m:
		o implemented flattened relationship handling in
			-EOEntity _parseRelationshipPath:
	* EOAccess/EOAccessFault.m:
		o fixed logs in -EOAccesFaultHandler dealloc
		o added [super dealloc] in -EOAccesFaultHandler dealloc
		o added logs in -EOAccessArrayFaultHandler dealloc
	* EOAdaptors/Postgres95/Postgres95Channel.m:
		o removed log
	* EOAccess/EOAdaptorChannel.m
		o Handle direct SQL query case in
			-dictionaryWithObjects:forAttributes:zone:
	* EOAccess/EOClassDescription.m
		o implement some cases in -addObject:toBothSidesOfRelationshipWithKey:
	* EOControl/EOGenericRecord.m:
		o avoid infinit loop in -description
	* EOAccess/EODatabaseContext.m
		o implement some cases in -entitiesOnWhichThisEntityDepends:
		o changed return type of -entitiesOnWhichThisEntityDepends:


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15108 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mguesdon 2002-11-26 09:58:22 +00:00
parent 896ab6bc6b
commit 12cd6865a8
9 changed files with 137 additions and 88 deletions

View file

@ -1,3 +1,25 @@
2002-11-26 Manuel Guesdon <mguesdon@orange-concept.com>
* EOAccess/EOEntity.m:
o implemented flattened relationship handling in
-EOEntity _parseRelationshipPath:
* EOAccess/EOAccessFault.m:
o fixed logs in -EOAccesFaultHandler dealloc
o added [super dealloc] in -EOAccesFaultHandler dealloc
o added logs in -EOAccessArrayFaultHandler dealloc
* EOAdaptors/Postgres95/Postgres95Channel.m:
o removed log
* EOAccess/EOAdaptorChannel.m
o Handle direct SQL query case in
-dictionaryWithObjects:forAttributes:zone:
* EOAccess/EOClassDescription.m
o implement some cases in -addObject:toBothSidesOfRelationshipWithKey:
* EOControl/EOGenericRecord.m:
o avoid infinit loop in -description
* EOAccess/EODatabaseContext.m
o implement some cases in -entitiesOnWhichThisEntityDepends:
o changed return type of -entitiesOnWhichThisEntityDepends:
2002-11-25 Richard Frith-macdonald <rfm@gnu.org>
Tagged all files as 'with-extensions'

View file

@ -138,6 +138,8 @@ NSString *EOAccessFaultObjectNotAvailableException = @"EOAccessFaultObjectNotAva
ASSIGNCOPY(gid, globalID);
ASSIGN(databaseContext, dbcontext);
ASSIGN(editingContext, ec);
EOFLOGObjectFnStopOrCond(@"EOAccesFaultHandler");
}
return self;

View file

@ -384,35 +384,44 @@ inRowsDescribedByQualifier: (EOQualifier *)qualifier
if (anAttribute)
{
EOEntity *entity = [anAttribute entity];
EOMKKDInitializer *initializer;
int i = 0;
int count = [attributes count];
NSAssert1(entity,@"No entity for attribute %@",anAttribute);
// We may not have entity for direct SQL calls
// We may not have entity for direct SQL calls
if (entity)
{
NSArray *attributesToFetch = [entity _attributesToFetch];
EOMKKDInitializer *initializer = [entity _adaptorDictionaryInitializer];
int i = 0;
int count = [attributes count];
//NSArray *attributesToFetch = [entity _attributesToFetch];
initializer = [entity _adaptorDictionaryInitializer];
}
else
{
initializer = [EOMKKDInitializer initializerFromKeyArray:
[attributes resultsOfPerformingSelector:
@selector(name)]];
};
NSDebugMLLog(@"gsdb",@"\ndictionaryWithObjects:forAttributes:zone: attributes=%@ objects=%p\n",attributes,objects);
NSAssert(initializer,@"No initializer");
NSDebugMLLog(@"gsdb",
@"\ndictionaryWithObjects:forAttributes:zone: attributes=%@ objects=%p\n",
attributes,objects);
NSAssert(initializer,@"No initializer");
NSDebugMLLog(@"gsdb",@"initializer=%@",initializer);
dict = [[[EOMutableKnownKeyDictionary allocWithZone: zone]
initWithInitializer:initializer] autorelease];
NSDebugMLLog(@"gsdb", @"dict=%@", dict);
NSDebugMLLog(@"gsdb",@"initializer=%@",initializer);
dict = [[[EOMutableKnownKeyDictionary allocWithZone: zone]
initWithInitializer:initializer] autorelease];
NSDebugMLLog(@"gsdb", @"dict=%@", dict);
for(i = 0; i < count; i++)
{
EOAttribute *attribute = (EOAttribute *)[attributes objectAtIndex: i];
NSDebugMLLog(@"gsdb", @"Attribute=%@ value=%@", attribute, objects[i]);
[dict setObject: objects[i]
forKey: [attribute name]];
}
for(i = 0; i < count; i++)
{
EOAttribute *attribute = (EOAttribute *)[attributes objectAtIndex: i];
NSDebugMLLog(@"gsdb", @"Attribute=%@ value=%@", attribute, objects[i]);
[dict setObject: objects[i]
forKey: [attribute name]];
}
}

View file

@ -254,7 +254,7 @@ It's invoked after prepareForSaveWithCoordinator:editingContext: and before owns
- (void) createAdaptorOperationsForDatabaseOperation: (EODatabaseOperation*)dbOpe;
- (NSArray*) orderAdaptorOperations;
- (id) entitiesOnWhichThisEntityDepends: (EOEntity *)entity;
- (NSArray*) entitiesOnWhichThisEntityDepends: (EOEntity *)entity;
-(NSArray*)entityNameOrderingArrayForEntities: (NSArray *)entities;
- (BOOL) isValidQualifierTypeForAttribute: (EOAttribute*)attribute;

View file

@ -4597,7 +4597,7 @@ Raises an exception is the adaptor is unable to perform the operations.
return orderedAdaptorOpe;
}
- (id) entitiesOnWhichThisEntityDepends: (EOEntity*)entity
- (NSArray*) entitiesOnWhichThisEntityDepends: (EOEntity*)entity
{
NSMutableArray *entities = nil;
NSArray *relationships = nil;
@ -4619,9 +4619,19 @@ Raises an exception is the adaptor is unable to perform the operations.
{
if ([relationship isFlattened])
{
NSEmitTODO();
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"relationship=%@", relationship);
[self notImplemented: _cmd]; //TODO-NOW
//TODO VERIFY
EOExpressionArray *definitionArray=[relationship _definitionArray];
EORelationship *firstRelationship=[definitionArray objectAtIndex:0];
EOEntity *firstDefEntity=[firstRelationship destinationEntity];
NSArray *defDependEntities=[self
entitiesOnWhichThisEntityDepends:firstDefEntity];
if ([defDependEntities count]>0)
{
if (!entities)
entities = [NSMutableArray array];
[entities addObjectsFromArray: defDependEntities];
};
}
else
{

View file

@ -3855,8 +3855,17 @@ toDestinationAttributeInLastComponentOfRelationshipPath: (NSString*)path
if ([relationship isFlattened])
{
NSEmitTODO(); //TODO
[self notImplemented: _cmd];//TODO
EOExpressionArray *definitionArray=[relationship _definitionArray];
NSDebugMLog(@"entityName=%@ path=%@",[self name],path);
NSDebugMLog(@"relationship=%@",relationship);
NSDebugMLog(@"relationship definitionArray=%@",definitionArray);
// For flattened relationships, we add relationship definition array
[expressionArray addObjectsFromArray:definitionArray];
// Use last relationship to find destinationEntity,...
relationship=[expressionArray lastObject];
}
else
{

View file

@ -341,8 +341,6 @@ zone:zone
}
NSDebugMLLog(@"gsdb", @"value[%d]=%@", i, values[i]);
NSDebugMLog(@"TEST attributesToFetch=%@", [[attr entity]
attributesToFetch]);
}
NSDebugMLLog(@"gsdb", @"values count=%d values=%p", count, values);

View file

@ -1456,8 +1456,9 @@ toBothSidesOfRelationshipWithKey: (NSString *)key
// See if inverse relationship is to-many or to-one
if ([object isToManyKey: inverseKey])
{
NSEmitTODO();
[self notImplemented:_cmd];
//TODO VERIFY
[object addObject:self
toPropertyWithKey:inverseKey];
}
else
{
@ -1468,9 +1469,9 @@ toBothSidesOfRelationshipWithKey: (NSString *)key
if (oldObject)
{
//TODO self removeObject:oldObject fromPropertyWithKey:key
NSEmitTODO();
[self notImplemented:_cmd];
//TODO VERIFY
[object removeObject:oldObject
fromPropertyWithKey:inverseKey];
}
// Just set self into object relationship property

View file

@ -782,7 +782,46 @@ static const char _c_id[2] = { _C_ID, NULL };
}
/** used in -decription for self toOne or toMany objects to avoid
infinite loop in description **/
- (NSString *)_shortDescription
{
NSArray *toManyKeys = nil;
NSArray *toOneKeys = nil;
NSEnumerator *enumerator = [dictionary keyEnumerator];
NSMutableDictionary *dict;
NSString *key = nil;
id obj = nil;
toManyKeys = [classDescription toManyRelationshipKeys];
toOneKeys = [classDescription toOneRelationshipKeys];
dict = [NSMutableDictionary dictionaryWithCapacity: [dictionary count]];
while ((key = [enumerator nextObject]))
{
obj = [dictionary objectForKey: key];
if (!obj)
[dict setObject: @"(null)"
forKey: key];
else
{
// print out only simple values
if ([toManyKeys containsObject: key] == NO
&& [toOneKeys containsObject: key] == NO)
{
[dict setObject: obj
forKey: key];
}
}
}
return [NSString stringWithFormat: @"<%s %p : classDescription=%@\nvalues=%@>",
object_get_class_name(self),
(void*)self,
classDescription,
dict];
}
- (NSString *)description
{
@ -793,36 +832,13 @@ static const char _c_id[2] = { _C_ID, NULL };
NSString *key = nil;
id obj = nil;
// printf("descr %p\n",self);
// EOFLOGObjectFnStartOrCond(@"EOGenericRecord");
/* int num=0;//TODELETE
EOFLOGObjectLevelArgs(@"EOGenericRecord",@"self=%p dict=%p enumerator=%@",self,dictionary,enumerator);
fflush(stdout);
fflush(stderr);
EOFLOGObjectLevelArgs(@"EOGenericRecord",@"classDescription=%@",classDescription);
fflush(stdout);
fflush(stderr);
*/
toManyKeys = [classDescription toManyRelationshipKeys];
toOneKeys = [classDescription toOneRelationshipKeys];
/*
EOFLOGObjectLevelArgs(@"EOGenericRecord",@"AAAA");
fflush(stdout);
fflush(stderr);
EOFLOGObjectLevelArgs(@"EOGenericRecord",@"toManyKeys=%@",toManyKeys);
fflush(stdout);
fflush(stderr);
EOFLOGObjectLevelArgs(@"EOGenericRecord",@"toOneKeys=%@",toOneKeys);
fflush(stdout);
fflush(stderr);
*/
dict = [NSMutableDictionary dictionaryWithCapacity: [dictionary count]];
// EOFLOGObjectLevelArgs(@"EOGenericRecord",@"Values nb=%d",[dictionary count]);
while ((key = [enumerator nextObject]))
{
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"%d key=%@", num, key);
obj = [dictionary objectForKey: key];
if (!obj)
@ -830,25 +846,16 @@ static const char _c_id[2] = { _C_ID, NULL };
forKey: key];
else
{
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"%d obj=%@", num, obj);
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"%d key=%@", num, key);
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"%d obj=%@", num, obj);
if ([toManyKeys containsObject: key] == NO
&& [toOneKeys containsObject: key] == NO)
{
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"%d SIMPLE VALUE", num);
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"%d dict=%@", num, dict);
[dict setObject: obj
forKey: key];
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"%d dict=%@", num, dict);
}
else
{
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"%d NOT SIMPLE VALUE", num);
if ([EOFault isFault: obj] == YES)
{
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"%d FAULT VALUE", num);
[dict setObject: [obj description]
forKey: key];
}
@ -858,23 +865,22 @@ static const char _c_id[2] = { _C_ID, NULL };
NSMutableArray *array;
id rel;
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"%d TO MANY VALUE", num);
array = [NSMutableArray arrayWithCapacity: 8];
toManyEnum = [obj objectEnumerator];
while ((rel = [toManyEnum nextObject]))
{
/* [array addObject:
[NSString
stringWithFormat:@"<%@: classDescription=%@>",
NSStringFromClass([obj class]),
[obj classDescription]]];
*/
NSString* relDescr;
// Avoid infinit loop
if ([rel respondsToSelector: @selector(_shortDescription)])
relDescr=[rel _shortDescription];
else
relDescr=[rel description];
[array addObject:
[NSString
stringWithFormat: @"<%@ %p>",
rel, NSStringFromClass([rel class])]];
relDescr, NSStringFromClass([rel class])]];
}
[dict setObject: [NSString stringWithFormat:
@ -884,7 +890,6 @@ static const char _c_id[2] = { _C_ID, NULL };
}
else
{
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"%d TO ONE VALUE", num);
[dict setObject: [NSString
stringWithFormat: @"<%p %@: classDescription=%@>",
obj,
@ -892,22 +897,15 @@ static const char _c_id[2] = { _C_ID, NULL };
[obj classDescription]]
forKey: key];
}
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"%d END VALUE", num);
}
}
}
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"END DESCR");
//EOFLOGObjectLevelArgs(@"EOGenericRecord", @"dictionary=%@", dictionary);
// EOFLOGObjectFnStopOrCond(@"EOGenericRecord");
// printf("end descr %p\n",self);
return [NSString stringWithFormat: @"<%s %p : classDescription=%@\nvalues=%@>",
object_get_class_name(self),
(void*)self,
classDescription,
dict];
// return @"<RECORD>";
}
//debug only