mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-22 19:01:04 +00:00
* EOAccess/EORelationship.m ([EORelationship
-foreignKeyInDestination]): use destinationEntity to search for pk. * EOAccess/EODatabaseContext.m ([EODatabaseContext -_buildPrimaryKeyGeneratorListForEditingContext:]): check if the relationship propagates the pk to an entity pk. ([EODatabaseContext -relayAttributesInRelationship:sourceObject: destinationObject:]): record updates for relationship with fk and the ones that propatates pk. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15295 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4ff95c2a36
commit
0d78e7210c
3 changed files with 86 additions and 57 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2002-12-14 Mirko Viviani <mirko.viviani@rccr.cremona.it>
|
||||||
|
|
||||||
|
* EOAccess/EORelationship.m ([EORelationship
|
||||||
|
-foreignKeyInDestination]): use destinationEntity to search for pk.
|
||||||
|
|
||||||
|
* EOAccess/EODatabaseContext.m ([EODatabaseContext
|
||||||
|
-_buildPrimaryKeyGeneratorListForEditingContext:]): check if the
|
||||||
|
relationship propagates the pk to an entity pk.
|
||||||
|
([EODatabaseContext -relayAttributesInRelationship:sourceObject:
|
||||||
|
destinationObject:]): record updates for relationship with fk and the
|
||||||
|
ones that propatates pk.
|
||||||
|
|
||||||
2002-12-08 Mirko Viviani <mirko.viviani@rccr.cremona.it>
|
2002-12-08 Mirko Viviani <mirko.viviani@rccr.cremona.it>
|
||||||
|
|
||||||
* EOAccess/EOEntity.m ([EOEntity -classDescriptionForInstances]):
|
* EOAccess/EOEntity.m ([EOEntity -classDescriptionForInstances]):
|
||||||
|
|
|
@ -3451,7 +3451,7 @@ Raises an exception is the adaptor is unable to perform the operations.
|
||||||
EOFLOGObjectFnStop();
|
EOFLOGObjectFnStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)relayAttributesInRelationship: (EORelationship*)relationship
|
- (void)relayAttributesInRelationship: (EORelationship*)relationship
|
||||||
sourceObject: (id)sourceObject
|
sourceObject: (id)sourceObject
|
||||||
destinationObjects: (NSArray*)destinationObjects
|
destinationObjects: (NSArray*)destinationObjects
|
||||||
{
|
{
|
||||||
|
@ -3526,7 +3526,7 @@ Raises an exception is the adaptor is unable to perform the operations.
|
||||||
objectForKey: @"destinationKeys"];//(customerCode)
|
objectForKey: @"destinationKeys"];//(customerCode)
|
||||||
NSArray *sourceKeys = [sourceToDestinationKeyMap
|
NSArray *sourceKeys = [sourceToDestinationKeyMap
|
||||||
objectForKey: @"sourceKeys"];//(code)
|
objectForKey: @"sourceKeys"];//(code)
|
||||||
NSMutableDictionary* sourceNewRow = [sourceDBOpe newRow];//OK in foreignKeyInDestination
|
NSMutableDictionary *sourceNewRow = [sourceDBOpe newRow];//OK in foreignKeyInDestination
|
||||||
BOOL foreignKeyInDestination = [relationship foreignKeyInDestination];
|
BOOL foreignKeyInDestination = [relationship foreignKeyInDestination];
|
||||||
int i, count;
|
int i, count;
|
||||||
|
|
||||||
|
@ -3548,7 +3548,7 @@ Raises an exception is the adaptor is unable to perform the operations.
|
||||||
NSAssert([destinationKeys count] == [sourceKeys count],
|
NSAssert([destinationKeys count] == [sourceKeys count],
|
||||||
@"destination keys count!=source keys count");
|
@"destination keys count!=source keys count");
|
||||||
|
|
||||||
if (foreignKeyInDestination)
|
if (foreignKeyInDestination || [relationship propagatesPrimaryKey])
|
||||||
{
|
{
|
||||||
relayedValues = [[[sourceNewRow valuesForKeys: sourceKeys]
|
relayedValues = [[[sourceNewRow valuesForKeys: sourceKeys]
|
||||||
mutableCopy] autorelease];// {code = 0; }
|
mutableCopy] autorelease];// {code = 0; }
|
||||||
|
@ -3559,8 +3559,8 @@ Raises an exception is the adaptor is unable to perform the operations.
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
id sourceKey = [sourceKeys objectAtIndex: i];
|
NSString *sourceKey = [sourceKeys objectAtIndex: i];
|
||||||
id destKey = [destinationKeys objectAtIndex: i];//customerCode
|
NSString *destKey = [destinationKeys objectAtIndex: i];
|
||||||
id sourceValue = [relayedValues objectForKey: sourceKey];
|
id sourceValue = [relayedValues objectForKey: sourceKey];
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"sourceKey=%@",
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"sourceKey=%@",
|
||||||
|
@ -3855,9 +3855,6 @@ Raises an exception is the adaptor is unable to perform the operations.
|
||||||
object: object
|
object: object
|
||||||
entity: entity]; //OK
|
entity: entity]; //OK
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EODatabaseContext",
|
|
||||||
@"CREATED databaseOpe=%@\nfor object %p",
|
|
||||||
databaseOpe, object);
|
|
||||||
EOFLOGObjectLevelArgs(@"EODatabaseContext",
|
EOFLOGObjectLevelArgs(@"EODatabaseContext",
|
||||||
@"CREATED databaseOpe=%@\nfor object %p %@",
|
@"CREATED databaseOpe=%@\nfor object %p %@",
|
||||||
databaseOpe, object, object);
|
databaseOpe, object, object);
|
||||||
|
@ -3968,6 +3965,7 @@ Raises an exception is the adaptor is unable to perform the operations.
|
||||||
|
|
||||||
return databaseOpe;
|
return databaseOpe;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)relayPrimaryKey: (NSDictionary*)pk
|
- (void)relayPrimaryKey: (NSDictionary*)pk
|
||||||
sourceObject: (id)sourceObject
|
sourceObject: (id)sourceObject
|
||||||
destObject: (id)destObject
|
destObject: (id)destObject
|
||||||
|
@ -4005,7 +4003,7 @@ Raises an exception is the adaptor is unable to perform the operations.
|
||||||
count = [values count];
|
count = [values count];
|
||||||
|
|
||||||
for (i = 0; nullPKValues && i < count; i++)
|
for (i = 0; nullPKValues && i < count; i++)
|
||||||
nullPKValues = ([values objectAtIndex:i] == [EONull null]);
|
nullPKValues = isNilOrEONull([values objectAtIndex:i]);
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"nullPKValues=%s",
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"nullPKValues=%s",
|
||||||
(nullPKValues ? "YES" : "NO"));
|
(nullPKValues ? "YES" : "NO"));
|
||||||
|
@ -4026,7 +4024,7 @@ Raises an exception is the adaptor is unable to perform the operations.
|
||||||
EOFLOGObjectFnStop();
|
EOFLOGObjectFnStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)relayPrimaryKey: (NSDictionary*)pk
|
- (void)relayPrimaryKey: (NSDictionary*)pk
|
||||||
object: (id)object
|
object: (id)object
|
||||||
entity: (EOEntity*)entity
|
entity: (EOEntity*)entity
|
||||||
{
|
{
|
||||||
|
@ -6691,9 +6689,27 @@ _numLocked = 0;
|
||||||
[destinationEntity name]);
|
[destinationEntity name]);
|
||||||
|
|
||||||
if (destinationEntity)
|
if (destinationEntity)
|
||||||
|
{
|
||||||
|
NSArray *destAttrs;
|
||||||
|
NSArray *pkAttrs;
|
||||||
|
int i, count;
|
||||||
|
BOOL destPK = NO;
|
||||||
|
|
||||||
|
destAttrs = [relationship destinationAttributes];
|
||||||
|
pkAttrs = [destinationEntity primaryKeyAttributes];
|
||||||
|
count = [destAttrs count];
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
if ([pkAttrs containsObject: [destAttrs
|
||||||
|
objectAtIndex: i]])
|
||||||
|
destPK = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (destPK)
|
||||||
{
|
{
|
||||||
EOFLOGObjectLevelArgs(@"EODatabaseContext",
|
EOFLOGObjectLevelArgs(@"EODatabaseContext",
|
||||||
@"destination entity: %@ No PrimaryKey Generation [Relatiuonship = %@]",
|
@"destination entity: %@ No PrimaryKey Generation [Relationship = %@]",
|
||||||
[destinationEntity name],
|
[destinationEntity name],
|
||||||
[relationship name]);
|
[relationship name]);
|
||||||
|
|
||||||
|
@ -6707,6 +6723,7 @@ _numLocked = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EOFLOGObjectFnStop();
|
EOFLOGObjectFnStop();
|
||||||
|
|
||||||
|
|
|
@ -1978,40 +1978,40 @@ becomes "name", and "FIRST_NAME" becomes "firstName".*/
|
||||||
return _sourceToDestinationKeyMap;
|
return _sourceToDestinationKeyMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL)foreignKeyInDestination
|
- (BOOL)foreignKeyInDestination
|
||||||
{
|
{
|
||||||
|
NSArray *destAttributes;
|
||||||
|
NSArray *primaryKeyAttributes;
|
||||||
|
int destAttributesCount;
|
||||||
|
int primaryKeyAttributesCount;
|
||||||
BOOL foreignKeyInDestination = NO;
|
BOOL foreignKeyInDestination = NO;
|
||||||
|
|
||||||
EOFLOGObjectFnStart();
|
EOFLOGObjectFnStart();
|
||||||
|
|
||||||
if ([self isToMany])
|
destAttributes = [self destinationAttributes];
|
||||||
{
|
primaryKeyAttributes = [[self destinationEntity] primaryKeyAttributes];
|
||||||
foreignKeyInDestination = YES;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NSArray *sourceAttributes = [self sourceAttributes];
|
|
||||||
NSArray *primaryKeyAttributes = [_entity primaryKeyAttributes];
|
|
||||||
int sourceAttributesCount = [sourceAttributes count];
|
|
||||||
int primaryKeyAttributesCount = [primaryKeyAttributes count];
|
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EORelationship", @"sourceAttributes=%@", sourceAttributes);
|
destAttributesCount = [destAttributes count];
|
||||||
EOFLOGObjectLevelArgs(@"EORelationship", @"primaryKeyAttributes=%@", primaryKeyAttributes);
|
primaryKeyAttributesCount = [primaryKeyAttributes count];
|
||||||
|
|
||||||
if (sourceAttributesCount > 0 && primaryKeyAttributesCount > 0)
|
EOFLOGObjectLevelArgs(@"EORelationship", @"destAttributes=%@",
|
||||||
|
destAttributes);
|
||||||
|
EOFLOGObjectLevelArgs(@"EORelationship", @"primaryKeyAttributes=%@",
|
||||||
|
primaryKeyAttributes);
|
||||||
|
|
||||||
|
if (destAttributesCount > 0 && primaryKeyAttributesCount > 0)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0;
|
for (i = 0;
|
||||||
!foreignKeyInDestination && i < sourceAttributesCount;
|
!foreignKeyInDestination && i < destAttributesCount;
|
||||||
i++) //TODO-VERIFY
|
i++)
|
||||||
{
|
{
|
||||||
EOAttribute *attribute = [sourceAttributes objectAtIndex: i];
|
EOAttribute *attribute = [destAttributes objectAtIndex: i];
|
||||||
int pkAttrIndex = [primaryKeyAttributes
|
int pkAttrIndex = [primaryKeyAttributes
|
||||||
indexOfObjectIdenticalTo: attribute];
|
indexOfObjectIdenticalTo: attribute];
|
||||||
|
|
||||||
foreignKeyInDestination = (pkAttrIndex != NSNotFound);
|
foreignKeyInDestination = (pkAttrIndex == NSNotFound);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue