Changes for OSX and fixes.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15865 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Mirko Viviani 2003-02-03 14:53:03 +00:00
parent 0339a722ef
commit 75e5869bb6
20 changed files with 592 additions and 148 deletions

View file

@ -1,3 +1,89 @@
2003-02-03 Stephane Corthesy <stephane@sente.ch>
* Postgres95Adaptor.m: made some changes to externalTypeNames (needs
to be reviewed completely!); avoided needless autoreleased object
* Postgres95Channel.m: avoided needless autoreleased object ; added
arg to NSDebugMLLog (should be replaced by other log macro); use
macros RETAIN, AUTORELASE; when invoking PQexec, added ending ";" to
statement (necessary for inserts, at least)
* Postgres95SQLExpression.m: replaced #import <EOAccess/EOAccess.h> by
smaller #imports; commented out use of external type 'datetime'
(obsolete?); corrected bug in +formatValue:forAttribute: (error when
escaping special characters); overloaded
+dropTableStatementsForEntityGroup: to append CASCADE (maybe this
should be done in EOSQLExpression class?), else it is not possible to
drop tables which contain foreign key constraints; overloaded
+prepareConstraintStatementForRelationship:sourceColumns:
destinationColumns: to append DEFERRABLE INITIALLY DEFERRED (maybe this
should be done in EOSQLExpression class?)
* Postgres95Values.h: made Postgres95Values inherit from NSObject, else
ObjC runtime doesn't like it and crashes!
* EOAdaptor.m: added #import <Foundation/NSData.h>; corrected bug when
instantiating adaptor: class name needs to be taken exclusively from
infoDictionary, because a framework's principalClass is indeterminate
(is it?); corrected var type; added empty implementation of
EOLoginPanel class (is the method named
"administraticeConnectionDictionaryForAdaptor:" correct? Shouldn't it
be "administrativeConnectionDictionaryForAdaptor:" ??)
* EOAttribute.m: added #include <string.h>; use -[NSTimeZone name]
instead of -[NSTimeZone timeZoneName] (also on GNUstep?)
* EODatabaseChannel.m: corrected bug with macro NSDebugMLog (which
should be replaced by other macro...); in -fetchObject, added support
for raw rows (works for me, but I'm not sure whether it is totally
correct: _fetchSpecifications ivar is used nowhere!); avoided use of
autoreleased objects; in
-_selectWithFetchSpecification:editingContext:, uncommented last part
to allow support for raw rows.
* EODatabaseContext.h: added #import <Foundation/NSDate.h>
* EODatabaseContext.m: #import <Foundation/NSKeyValueCoding.h> only
when FOUNDATION_HAS_KVC? ; added declaration of -entityForGlobalID:;
replaced some retain by RETAIN; in
objectsWithFetchSpecification:editingContext:, added support for raw
rows (adapted code of non raw rows => needs refactoring); added missing
cast; corrected bug with macro NSDebugMLog (which should be replaced by
other macro...)
* EODatabaseDatasource.m: added #import <Foundation/NSEnumerator.h>;
added declaration of
-_partialInitWithEditingContext:entityName:fetchSpecificationName:
* EOEntity.m: corrected bugs with lazy loading of ivars by using
_flags.updating, in -initWithPropertyList:owner:, and by using methods
instead of direct access to ivars; in -classProperties, corrected
problem with vars containing sometimes strings, sometimes
EOAttribute/EORelationship! (very weird way of lazy initialization...
Should be reviewed); added use of _flags.updating in -relationships and
-attributes; in -isPrimaryKeyValidInObject:, no longer tests against
[NSNull null], because [EONull null] == [NSNull null]; replaced some
retain by RETAIN; in -addAttribute:, -removeAttribute:,
-addRelationship: and -removeRelationship:, corrected nasty bug due to
mutableCopy: now we are independant of mutableCopy implementation (deep
or shallow copy), as implementation changed these last days and might
change again. Added -_setClassName: to allow modification without
calling willChange, when necessary (init); modified _setIsEdited to
test _flags.updating; in -awakeObject:fromInsertionInEditingContext:,
corrected conditions to create relationship (propagatesPrimaryKey has
nothing to do with it, whereas isMandatory is important)
* EOModel.m: added #include <gnustep/base/GSObjCRuntime.h> and #import
<Foundation/NSPathUtilities.h>; changed search strategy for models by
using NSSearchPathForDirectoriesInDomains(); replaced some retain by
RETAIN; avoided use of mutableCopy and copy
* EORelationship.m: replaced some retain by RETAIN; avoided use of
mutableCopy and copy
* EOSQLExpression.m: added declaration of +sqlExpressionWithEntity:;
added +foreignKeyConstraintStatementsForEntityGroup: and
+foreignKeyConstraintStatementsForEntityGroups:; in
+createTableStatementsForEntityGroup:, corrected call to listString; in
+schemaCreationStatementsForEntities:options:, reordered defaults[] to
allow correct SQL generation (you drop first, then create) and
corrected method to invoke for EOForeignKeyConstraintsKey; corrected
-columnTypeStringForAttribute: and -addCreateClauseForAttribute:
* EOSchemaGeneration.h: corrected documentation
* EOStoredProcedure.m: added #import <Foundation/NSEnumerator.h>
* EOUtilities.h: removed duplicate delcaration of -objectsOfClass:
* EOUtilities.m: added #import <EOControl/EOGenericRecord.h>; corrected
bug with macro NSDebugMLog (which should be replaced by other
macro...); corrected type casting; added type casting.
2003-02-02 Mirko Viviani <mirko.viviani@rccr.cremona.it> 2003-02-02 Mirko Viviani <mirko.viviani@rccr.cremona.it>
* EOControl/EOGenericRecord.m ([EOGenericRecord +initialize]): import * EOControl/EOGenericRecord.m ([EOGenericRecord +initialize]): import

View file

@ -56,6 +56,7 @@ RCS_ID("$Id$")
#import <Foundation/NSProcessInfo.h> #import <Foundation/NSProcessInfo.h>
#import <Foundation/NSException.h> #import <Foundation/NSException.h>
#import <Foundation/NSFileManager.h> #import <Foundation/NSFileManager.h>
#import <Foundation/NSData.h>
#import <Foundation/NSDebug.h> #import <Foundation/NSDebug.h>
#import <EOAccess/EOAdaptor.h> #import <EOAccess/EOAdaptor.h>
@ -224,15 +225,14 @@ NSString *EOGeneralAdaptorException = @"EOGeneralAdaptorException";
property list containing one entry whose key is adaptorClassName. It property list containing one entry whose key is adaptorClassName. It
identifies the actual adaptor class from the bundle. */ identifies the actual adaptor class from the bundle. */
adaptorClass = [bundle principalClass]; //NSString* adaptorClassName=[infoDictionary objectForKey:@"EOAdaptorClassName"]; ?? if(![bundle isLoaded])
NSLog(@"Loaded %@? %@", bundle, ([bundle load]? @"YES":@"NO"));
if (adaptorClass == Nil) { adaptorClassName = [[bundle infoDictionary] objectForKey: @"EOAdaptorClassName"];
adaptorClassName = [[bundle infoDictionary] objectForKey: @"EOAdaptorClassName"];
NSLog(@"adaptorClassName is %@", adaptorClassName); NSLog(@"adaptorClassName is %@", adaptorClassName);
adaptorClass = NSClassFromString(adaptorClassName); adaptorClass = NSClassFromString(adaptorClassName);
}
if(!adaptorClass) if(!adaptorClass)
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
@ -438,7 +438,7 @@ NSString *EOGeneralAdaptorException = @"EOGeneralAdaptorException";
{ {
NSString *encodingString=nil; NSString *encodingString=nil;
NSDictionary *encodingsDict = [self connectionDictionary]; NSDictionary *encodingsDict = [self connectionDictionary];
NSStringEncoding *availableEncodingsArray; const NSStringEncoding *availableEncodingsArray;
int count = 0; int count = 0;
NSStringEncoding availableEncodingValue; NSStringEncoding availableEncodingValue;
NSString *availableEncodingString; NSString *availableEncodingString;
@ -726,3 +726,19 @@ NSString *EOGeneralAdaptorException = @"EOGeneralAdaptorException";
} }
@end @end
@implementation EOLoginPanel
- (NSDictionary *) runPanelForAdaptor: (EOAdaptor *)adaptor validate: (BOOL)yn
{
[self subclassResponsibility: _cmd];
return nil;
}
- (NSDictionary *) administraticeConnectionDictionaryForAdaptor: (EOAdaptor *)adaptor
{
[self subclassResponsibility: _cmd];
return nil;
}
@end

View file

@ -39,6 +39,7 @@
RCS_ID("$Id$") RCS_ID("$Id$")
#include <ctype.h> #include <ctype.h>
#include <string.h>
#import <Foundation/NSUtilities.h> #import <Foundation/NSUtilities.h>
#import <Foundation/NSArchiver.h> #import <Foundation/NSArchiver.h>
@ -251,7 +252,7 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
if (_name) if (_name)
[propertyList setObject: _name forKey: @"name"]; [propertyList setObject: _name forKey: @"name"];
if (_serverTimeZone) if (_serverTimeZone)
[propertyList setObject: [_serverTimeZone timeZoneName] [propertyList setObject: [_serverTimeZone name]
forKey: @"serverTimeZone"]; forKey: @"serverTimeZone"];
if (_columnName) if (_columnName)
[propertyList setObject: _columnName forKey: @"columnName"]; [propertyList setObject: _columnName forKey: @"columnName"];

View file

@ -277,7 +277,7 @@ RCS_ID("$Id$")
if (![self isFetchInProgress]) if (![self isFetchInProgress])
{ {
NSLog(@"No Fetch in progress"); NSLog(@"No Fetch in progress");
NSDebugMLog(@"No Fetch in progress"); NSDebugMLog(@"No Fetch in progress", "");
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: no fetch in progress", format: @"%@ -- %@ 0x%x: no fetch in progress",
@ -312,6 +312,10 @@ RCS_ID("$Id$")
adaptorContext transactionDidCommit adaptorContext transactionDidCommit
*/ */
} }
else if([[_fetchSpecifications lastObject] fetchesRawRows]) // Testing against only one should be enough
{
object = [NSDictionary dictionaryWithDictionary:row];
}
else else
{ {
BOOL isObjectNew = YES; //TODO used to avoid double fetch. We should see how to do when isRefreshingObjects == YES BOOL isObjectNew = YES; //TODO used to avoid double fetch. We should see how to do when isRefreshingObjects == YES
@ -680,12 +684,13 @@ RCS_ID("$Id$")
{ {
EOFetchSpecification *fetchSubEntity; EOFetchSpecification *fetchSubEntity;
fetchSubEntity = [[fetch copy] autorelease]; fetchSubEntity = [fetch copy];
[fetchSubEntity setEntityName: [entity name]]; [fetchSubEntity setEntityName: [entity name]];
[array addObjectsFromArray: [array addObjectsFromArray:
[context objectsWithFetchSpecification: [context objectsWithFetchSpecification:
fetchSubEntity]]; fetchSubEntity]];
[fetchSubEntity release];
} }
} }
} }
@ -747,7 +752,7 @@ RCS_ID("$Id$")
([self isFetchInProgress] ? "YES" : "NO")); ([self isFetchInProgress] ? "YES" : "NO"));
//TODO: verify //TODO: verify
/* // (stephane@sente.ch) Uncommented end to allow rawRow fetches
if([_databaseContext updateStrategy] == EOUpdateWithPessimisticLocking if([_databaseContext updateStrategy] == EOUpdateWithPessimisticLocking
&& ![[_databaseContext adaptorContext] transactionNestingLevel]) && ![[_databaseContext adaptorContext] transactionNestingLevel])
[NSException raise:NSInvalidArgumentException [NSException raise:NSInvalidArgumentException
@ -770,9 +775,9 @@ RCS_ID("$Id$")
[_fetchSpecifications addObject:fetch]; [_fetchSpecifications addObject:fetch];
[self setCurrentEntity:[[_databaseContext database] // [self setCurrentEntity:[[_databaseContext database]
entityNamed:[fetch entityName]]];//done // entityNamed:[fetch entityName]]];//done
[self setCurrentEditingContext:context];//done // [self setCurrentEditingContext:context];//done
[self setIsLocking:([_databaseContext updateStrategy] == [self setIsLocking:([_databaseContext updateStrategy] ==
EOUpdateWithPessimisticLocking ? EOUpdateWithPessimisticLocking ?
@ -780,21 +785,21 @@ RCS_ID("$Id$")
[fetch locksObjects])]; [fetch locksObjects])];
[self setIsRefreshingObjects:[fetch refreshesRefetchedObjects]]; [self setIsRefreshingObjects:[fetch refreshesRefetchedObjects]];
attributesToFetch = [_currentEntity attributesToFetch];//done // attributesToFetch = [_currentEntity attributesToFetch];//done
EOFLOGObjectLevelArgs(@"gsdb",@"[_adaptorChannel class]: %@",[_adaptorChannel class]); // EOFLOGObjectLevelArgs(@"gsdb",@"[_adaptorChannel class]: %@",[_adaptorChannel class]);
[_adaptorChannel selectAttributes:attributesToFetch // [_adaptorChannel selectAttributes:attributesToFetch
fetchSpecification:fetch // fetchSpecification:fetch
lock:_isLocking // lock:_isLocking
entity:_currentEntity];//done // entity:_currentEntity];//done
[_fetchProperties addObjectsFromArray:attributesToFetch]; [_fetchProperties addObjectsFromArray:[self _propertiesToFetch]];
if(_delegateRespondsTo.didSelectObjects) if(_delegateRespondsTo.didSelectObjects)
[_delegate databaseContext:_databaseContext [_delegate databaseContext:_databaseContext
didSelectObjectsWithFetchSpecification:fetch didSelectObjectsWithFetchSpecification:fetch
databaseChannel:self]; databaseChannel:self];
*/
EOFLOGObjectFnStop(); EOFLOGObjectFnStop();
} }

View file

@ -32,6 +32,7 @@
#import <Foundation/NSHashTable.h> #import <Foundation/NSHashTable.h>
#import <Foundation/NSMapTable.h> #import <Foundation/NSMapTable.h>
#import <Foundation/NSLock.h> #import <Foundation/NSLock.h>
#import <Foundation/NSDate.h>
#import <EOControl/EOObjectStoreCoordinator.h> #import <EOControl/EOObjectStoreCoordinator.h>

View file

@ -49,6 +49,11 @@ RCS_ID("$Id$")
#import <Foundation/NSSet.h> #import <Foundation/NSSet.h>
#import <Foundation/NSData.h> #import <Foundation/NSData.h>
#import <Foundation/NSDebug.h> #import <Foundation/NSDebug.h>
#if FOUNDATION_HAS_KVC
#import <Foundation/NSKeyValueCoding.h>
#endif
#include <string.h>
#import <EOAccess/EOAdaptor.h> #import <EOAccess/EOAdaptor.h>
#import <EOAccess/EOAdaptorChannel.h> #import <EOAccess/EOAdaptorChannel.h>
@ -98,6 +103,10 @@ NSString *EODatabaseOperationsKey = @"EODatabaseOperationsKey";
NSString *EOFailedDatabaseOperationKey = @"EOFailedDatabaseOperationKey"; NSString *EOFailedDatabaseOperationKey = @"EOFailedDatabaseOperationKey";
@interface EODatabaseContext(EOObjectStoreSupportPrivate)
- (id) entityForGlobalID: (EOGlobalID *)globalID;
@end
@implementation EODatabaseContext @implementation EODatabaseContext
// Initializing instances // Initializing instances
@ -186,7 +195,7 @@ static Class _contextClass = Nil;
if ((self = [super init])) if ((self = [super init]))
{ {
_adaptorContext = [[[database adaptor] createAdaptorContext] retain]; _adaptorContext = RETAIN([[database adaptor] createAdaptorContext]);
if (_adaptorContext == nil) if (_adaptorContext == nil)
{ {
@ -195,7 +204,7 @@ static Class _contextClass = Nil;
return nil; return nil;
} }
_database = [database retain]; _database = RETAIN(database);
// Register this object into database // Register this object into database
[_database registerContext: self]; [_database registerContext: self];
@ -608,7 +617,7 @@ May raise an exception if transaction has began or if you want pessimistic lock
DESTROY(_registeredChannels); DESTROY(_registeredChannels);
_adaptorContext = [[[[self database] adaptor] createAdaptorContext] retain]; _adaptorContext = RETAIN([[[self database] adaptor] createAdaptorContext]);
_registeredChannels = [NSMutableArray new]; _registeredChannels = [NSMutableArray new];
EOFLOGObjectFnStopOrCond2(@"DatabaseLevel", @"EODatabaseContext"); EOFLOGObjectFnStopOrCond2(@"DatabaseLevel", @"EODatabaseContext");
@ -1339,12 +1348,196 @@ userInfo = {
*/ */
rawRowKeyPaths = [fetch rawRowKeyPaths];//OK rawRowKeyPaths = [fetch rawRowKeyPaths];//OK
if (rawRowKeyPaths) if (rawRowKeyPaths)
#if 0
{ {
NSEmitTODO(); NSEmitTODO();
[self notImplemented: _cmd]; //TODO [self notImplemented: _cmd]; //TODO
} }
#else
// (stephane@sente.ch) Adapted implementation of non raw rows
{
//cachesObject
//fetchspe isDeep ret 1
channel = [self _obtainOpenChannel];
if ([entity cachesObjects] == YES)//OK if (!channel)
{
NSEmitTODO();
[self notImplemented: _cmd];//TODO
}
else
{
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"channel class %@ [channel isFetchInProgress]=%s",
[channel class],
([channel isFetchInProgress] ? "YES" : "NO"));
NSLog(@"%@ -- %@ 0x%x: channel isFetchInProgress=%s",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
([channel isFetchInProgress] ? "YES" : "NO"));
//mirko:
#if 0
if (_flags.beganTransaction == NO
&& _updateStrategy == EOUpdateWithPessimisticLocking)
{
[_adaptorContext beginTransaction];
EOFLOGObjectLevel(@"EODatabaseContext",
@"BEGAN TRANSACTION FLAG==>YES");
_flags.beganTransaction = YES;
}
#endif
if ([entity isAbstractEntity] == NO) //Mirko ???
// (stephane@sente) Should we test deepInheritanceFetch?
{
int autoreleaseSteps = 20;
int autoreleaseStep = autoreleaseSteps;
BOOL promptsAfterFetchLimit = NO;
NSAutoreleasePool *arp = nil;//To avoid too much memory use when fetching a lot of objects
int limit = 0;
[channel selectObjectsWithFetchSpecification: fetch
editingContext: context];//OK
EOFLOGObjectLevelArgs(@"EODatabaseContext",
@"[channel isFetchInProgress]=%s",
([channel isFetchInProgress] ? "YES" : "NO"));
limit = [fetch fetchLimit];//OK
promptsAfterFetchLimit = [fetch promptsAfterFetchLimit];
EOFLOGObjectLevel(@"EODatabaseContext", @"Will Fetch");
NS_DURING
{
arp = [NSAutoreleasePool new];
EOFLOGObjectLevelArgs(@"EODatabaseContext",
@"[channel isFetchInProgress]=%s",
([channel isFetchInProgress] ? "YES" : "NO"));
while ((obj = [channel fetchObject]))
{
EOFLOGObjectLevel(@"EODatabaseContext",
@"fetched an object");
EOFLOGObjectLevelArgs(@"EODatabaseContext",
@"FETCH OBJECT object=%@\n\n",
obj);
EOFLOGObjectLevelArgs(@"EODatabaseContext",
@"%d usesDistinct: %s",
num,
(usesDistinct ? "YES" : "NO"));
EOFLOGObjectLevelArgs(@"EODatabaseContext",
@"object=%@\n\n", obj);
if (usesDistinct == YES && num)
// (stephane@sente) I thought that DISTINCT was done on server-side?!?
{
for (i = 0; i < num; i++)
{
if ([[array objectAtIndex: i]
isEqual: obj] == YES)
{
obj = nil;
break;
}
}
if (obj == nil)
continue;
}
EOFLOGObjectLevel(@"EODatabaseContext",
@"AFTER FETCH");
[array addObject: obj];
EOFLOGObjectLevelArgs(@"EODatabaseContext",
@"array count=%d",
[array count]);
num++;
if (limit > 0 && num >= limit)
{
if ([[context messageHandler]
editingContext: context
shouldContinueFetchingWithCurrentObjectCount: num
originalLimit: limit
objectStore: self] == YES)
limit = 0;//??
else
break;
}
if (autoreleaseStep <= 0)
{
DESTROY(arp);
autoreleaseStep = autoreleaseSteps;
arp = [NSAutoreleasePool new];
}
else
autoreleaseStep--;
EOFLOGObjectLevel(@"EODatabaseContext",
@"WILL FETCH NEXT OBJECT");
EOFLOGObjectLevelArgs(@"EODatabaseContext",
@"[channel isFetchInProgress]=%s",
([channel isFetchInProgress] ? "YES" : "NO"));
}
EOFLOGObjectLevel(@"EODatabaseContext",
@"finished fetch");
EOFLOGObjectLevelArgs(@"EODatabaseContext",
@"array=%@", array);
EOFLOGObjectLevelArgs(@"EODatabaseContext",
@"step 0 channel is busy=%d",
(int)[channel isFetchInProgress]);
[channel cancelFetch]; //OK
EOFLOGObjectLevelArgs(@"EODatabaseContext",
@"step 1 channel is busy=%d",
(int)[channel isFetchInProgress]);
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"array=%@",
array);
//TODO
/*
handle exceptio in fetchObject
channel fetchObject
if eception:
if ([editcontext handleError:localException])
{
//TODO
}
else
{
//TODO
};
*/
}
NS_HANDLER
{
EOFLOGObjectLevelArgs(@"EODatabaseContext",
@"AN EXCEPTION: %@",
localException);
RETAIN(localException);
DESTROY(arp);
[localException autorelease];
[localException raise];
}
NS_ENDHANDLER;
}
}
EOFLOGObjectLevelArgs(@"EODatabaseContext",
@"step 2 channel is busy=%d",
(int)[channel isFetchInProgress]);
}
#endif
else if ([entity cachesObjects] == YES)//OK
{ {
///TODO MG!!! ///TODO MG!!!
NSMutableArray *cache; NSMutableArray *cache;
@ -1656,7 +1849,7 @@ userInfo = {
@"AN EXCEPTION: %@", @"AN EXCEPTION: %@",
localException); localException);
[localException retain]; RETAIN(localException);
DESTROY(arp); DESTROY(arp);
[localException autorelease]; [localException autorelease];
[localException raise]; [localException raise];
@ -3927,9 +4120,9 @@ Raises an exception is the adaptor is unable to perform the operations.
forKey: key]; forKey: key];
} }
newRow = [[[NSMutableDictionary alloc] newRow = [[NSMutableDictionary alloc]
initWithDictionary: snapshot initWithDictionary: snapshot
copyItems: NO] autorelease]; copyItems: NO];
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"newRow=%@", newRow); EOFLOGObjectLevelArgs(@"EODatabaseContext", @"newRow=%@", newRow);
@ -3958,6 +4151,7 @@ Raises an exception is the adaptor is unable to perform the operations.
[databaseOpe setNewRow: newRow]; [databaseOpe setNewRow: newRow];
[self recordDatabaseOperation: databaseOpe]; [self recordDatabaseOperation: databaseOpe];
[newRow release];
} }
} }
NS_HANDLER NS_HANDLER
@ -5254,7 +5448,7 @@ Raises an exception is the adaptor is unable to perform the operations.
{ {
/*Class targetClass = Nil; /*Class targetClass = Nil;
void *extraData = NULL;*/ void *extraData = NULL;*/
EOAccessArrayFaultHandler *handler = [EOFault handlerForFault:object]; EOAccessArrayFaultHandler *handler = (EOAccessArrayFaultHandler *)[EOFault handlerForFault:object];
EOEditingContext *context = [handler editingContext]; EOEditingContext *context = [handler editingContext];
NSString *relationshipName= [handler relationshipName]; NSString *relationshipName= [handler relationshipName];
EOKeyGlobalID *gid = [handler sourceGlobalID]; EOKeyGlobalID *gid = [handler sourceGlobalID];
@ -5756,7 +5950,7 @@ Raises an exception is the adaptor is unable to perform the operations.
else else
{ {
NSEmitTODO(); NSEmitTODO();
NSWarnLog(@"_uniqueStack is empty. May be there's no runing transaction !"); NSWarnLog(@"_uniqueStack is empty. May be there's no runing transaction !", "");
[self notImplemented: _cmd]; //TODO [self notImplemented: _cmd]; //TODO
} }
@ -6196,11 +6390,10 @@ Raises an exception is the adaptor is unable to perform the operations.
if ([_uniqueStack count] > 0) if ([_uniqueStack count] > 0)
{ {
NSMutableDictionary *snapshotsDict = [[[_uniqueStack lastObject] NSMutableDictionary *snapshotsDict = [RETAIN([_uniqueStack lastObject]) autorelease];
retain] autorelease]; NSMutableDictionary *toManySnapshotsDict = [RETAIN([_uniqueArrayStack
NSMutableDictionary *toManySnapshotsDict = [[[_uniqueArrayStack lastObject])
lastObject] retain] autorelease];
autorelease];
/*NSMutableDictionary *deleteSnapshotsDict = [[[_deleteStack lastObject] /*NSMutableDictionary *deleteSnapshotsDict = [[[_deleteStack lastObject]
retain] autorelease];*/ //?? retain] autorelease];*/ //??

View file

@ -46,6 +46,7 @@ RCS_ID("$Id$")
#import <Foundation/NSCoder.h> #import <Foundation/NSCoder.h>
#import <Foundation/NSEnumerator.h> #import <Foundation/NSEnumerator.h>
#import <Foundation/NSDebug.h> #import <Foundation/NSDebug.h>
#import <Foundation/NSEnumerator.h>
#import <EOAccess/EODatabaseDataSource.h> #import <EOAccess/EODatabaseDataSource.h>
#import <EOAccess/EOEntity.h> #import <EOAccess/EOEntity.h>
@ -63,6 +64,13 @@ RCS_ID("$Id$")
#import <EOControl/EODebug.h> #import <EOControl/EODebug.h>
@interface EODatabaseDataSource(Private)
- (id)_partialInitWithEditingContext: (EOEditingContext*)editingContext
entityName: (NSString*)entityName
fetchSpecificationName: (NSString*)fetchSpecificationName;
@end
@implementation EODatabaseDataSource @implementation EODatabaseDataSource
- initWithEditingContext: (EOEditingContext *)editingContext - initWithEditingContext: (EOEditingContext *)editingContext

View file

@ -38,6 +38,7 @@ RCS_ID("$Id$")
#import <Foundation/NSException.h> #import <Foundation/NSException.h>
#import <Foundation/NSEnumerator.h> #import <Foundation/NSEnumerator.h>
#import <Foundation/NSDebug.h> #import <Foundation/NSDebug.h>
#import <Foundation/NSEnumerator.h>
#import <EOAccess/EODatabaseOperation.h> #import <EOAccess/EODatabaseOperation.h>
#import <EOAccess/EOAttribute.h> #import <EOAccess/EOAttribute.h>

View file

@ -42,8 +42,6 @@ RCS_ID("$Id$")
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <gnustep/base/GCObject.h>
#import <EOAccess/EOModel.h> #import <EOAccess/EOModel.h>
#import <EOAccess/EOEntity.h> #import <EOAccess/EOEntity.h>
#import <EOAccess/EOEntityPriv.h> #import <EOAccess/EOEntityPriv.h>
@ -99,10 +97,13 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
NSArray *array = nil; NSArray *array = nil;
NSString *tmpString = nil; NSString *tmpString = nil;
id tmpObject = nil; id tmpObject = nil;
_flags.updating = YES;
ASSIGN(_name, [propertyList objectForKey: @"name"]); ASSIGN(_name, [propertyList objectForKey: @"name"]);
// ASSIGN(_externalName,[propertyList objectForKey: @"externalName"]);
[self setExternalName: [propertyList objectForKey: @"externalName"]]; [self setExternalName: [propertyList objectForKey: @"externalName"]];
// ASSIGN(_externalQuery, [propertyList objectForKey: @"externalQuery"]);
[self setExternalQuery: [self setExternalQuery:
[propertyList objectForKey: @"externalQuery"]]; [propertyList objectForKey: @"externalQuery"]];
@ -152,6 +153,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
[tmpString class], [tmpString class],
tmpString);*/ tmpString);*/
//[self setUserInfo:[tmpString propertyList]]; //[self setUserInfo:[tmpString propertyList]];
// ASSIGN(_userInfo, tmpObject);
[self setUserInfo: tmpObject]; [self setUserInfo: tmpObject];
} }
@ -160,8 +162,11 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
EOFLOGObjectLevelArgs(@"EOEntity", @"tmpObject=%@ [%@]", EOFLOGObjectLevelArgs(@"EOEntity", @"tmpObject=%@ [%@]",
tmpObject, [tmpObject class]); tmpObject, [tmpObject class]);
// ASSIGN(_internalInfo, tmpObject);
[self _setInternalInfo: tmpObject]; [self _setInternalInfo: tmpObject];
// ASSIGN(_docComment, [propertyList objectForKey:@"docComment"]);
[self setDocComment:[propertyList objectForKey:@"docComment"]]; [self setDocComment:[propertyList objectForKey:@"docComment"]];
// [self _setClassName:[propertyList objectForKey: @"className"]];
[self setClassName: [propertyList objectForKey: @"className"]]; [self setClassName: [propertyList objectForKey: @"className"]];
[self setIsAbstractEntity: [self setIsAbstractEntity:
[[propertyList objectForKey: @"isAbstractEntity"] boolValue]]; [[propertyList objectForKey: @"isAbstractEntity"] boolValue]];
@ -321,7 +326,8 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
} }
} }
[self setCreateMutableObjects: NO]; //?? TC say no, mirko yes [self setCreateMutableObjects: NO]; //?? TC say no, mirko yes
_flags.updating = NO;
} }
} }
NS_HANDLER NS_HANDLER
@ -1004,8 +1010,13 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
#if 0
NSString *classPropertyName = [classPropertiesList NSString *classPropertyName = [classPropertiesList
objectAtIndex: i]; objectAtIndex: i];
#else
NSString *classPropertyName = ([[classPropertiesList objectAtIndex:i] isKindOfClass:[NSString class]] ? [classPropertiesList objectAtIndex:i]:[[classPropertiesList
objectAtIndex: i] name]);
#endif
id classProperty = [self attributeNamed: classPropertyName]; id classProperty = [self attributeNamed: classPropertyName];
if (!classProperty) if (!classProperty)
@ -1144,6 +1155,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
_flags.relationshipsIsLazy = NO; _flags.relationshipsIsLazy = NO;
[EOObserverCenter suppressObserverNotification]; [EOObserverCenter suppressObserverNotification];
_flags.updating = YES;
NS_DURING NS_DURING
{ {
@ -1250,6 +1262,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
DESTROY(relationshipPLists); DESTROY(relationshipPLists);
_flags.updating = NO;
[EOObserverCenter enableObserverNotification]; [EOObserverCenter enableObserverNotification];
[localException raise]; [localException raise];
} }
@ -1257,6 +1270,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
DESTROY(relationshipPLists); DESTROY(relationshipPLists);
_flags.updating = NO;
[EOObserverCenter enableObserverNotification]; [EOObserverCenter enableObserverNotification];
} }
else else
@ -1308,6 +1322,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
_flags.attributesIsLazy = NO; _flags.attributesIsLazy = NO;
[EOObserverCenter suppressObserverNotification]; [EOObserverCenter suppressObserverNotification];
_flags.updating = YES;
NS_DURING NS_DURING
{ {
@ -1447,6 +1462,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
NS_HANDLER NS_HANDLER
{ {
DESTROY(attributePLists); DESTROY(attributePLists);
_flags.updating = NO;
[EOObserverCenter enableObserverNotification]; [EOObserverCenter enableObserverNotification];
[localException raise]; [localException raise];
} }
@ -1454,6 +1470,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
DESTROY(attributePLists); DESTROY(attributePLists);
_flags.updating = NO;
[EOObserverCenter enableObserverNotification]; [EOObserverCenter enableObserverNotification];
[_attributes sortUsingSelector: @selector(eoCompareOnName:)];//Very important to have always the same order. [_attributes sortUsingSelector: @selector(eoCompareOnName:)];//Very important to have always the same order.
} }
@ -1704,7 +1721,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
NS_DURING NS_DURING
{ {
value = [object valueForKey: key]; value = [object valueForKey: key];
if (value == nil || value == [EONull null] || value == [NSNull null]) if (value == nil || value == [EONull null])
isValid = NO; isValid = NO;
} }
NS_HANDLER NS_HANDLER
@ -1990,8 +2007,8 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
if ([self createsMutableObjects]) if ([self createsMutableObjects])
[(GCMutableArray *)_attributes addObject: attribute]; [(GCMutableArray *)_attributes addObject: attribute];
else else
_attributes = [[[_attributes autorelease] _attributes = RETAIN([[_attributes autorelease]
arrayByAddingObject: attribute] retain]; arrayByAddingObject: attribute]);
if (_attributesByName == nil) if (_attributesByName == nil)
{ {
@ -2015,9 +2032,9 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
[(GCMutableArray *)_attributes removeObject: attribute]; [(GCMutableArray *)_attributes removeObject: attribute];
else else
{ {
_attributes = [[_attributes autorelease] mutableCopy]; _attributes = [[GCMutableArray alloc] initWithArray:[_attributes autorelease] copyItems:NO];
[(GCMutableArray *)_attributes removeObject: attribute]; [(GCMutableArray *)_attributes removeObject: attribute];
_attributes = [[_attributes autorelease] copy]; _attributes = [[GCArray alloc] initWithArray:[_attributes autorelease] copyItems:NO];
} }
[_attributesByName removeObjectForKey: [attribute name]]; [_attributesByName removeObjectForKey: [attribute name]];
[self _setIsEdited];//To clean caches [self _setIsEdited];//To clean caches
@ -2047,8 +2064,8 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
if ([self createsMutableObjects]) if ([self createsMutableObjects])
[(GCMutableArray *)_relationships addObject: relationship]; [(GCMutableArray *)_relationships addObject: relationship];
else else
_relationships = [[[_relationships autorelease] _relationships = RETAIN([[_relationships autorelease]
arrayByAddingObject: relationship] retain]; arrayByAddingObject: relationship]);
[relationship setEntity: self]; [relationship setEntity: self];
[self _setIsEdited];//To clean caches [self _setIsEdited];//To clean caches
@ -2063,13 +2080,15 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
{ {
[relationship setEntity:nil]; [relationship setEntity:nil];
if(_relationshipsByName != nil)
[_relationshipsByName removeObjectForKey:[relationship name]];
if ([self createsMutableObjects]) if ([self createsMutableObjects])
[(GCMutableArray *)_relationships removeObject: relationship]; [(GCMutableArray *)_relationships removeObject: relationship];
else else
{ {
_relationships = [[_relationships autorelease] mutableCopy]; _relationships = [[GCMutableArray alloc] initWithArray:[_relationships autorelease] copyItems:NO];
[(GCMutableArray *)_relationships removeObject: relationship]; [(GCMutableArray *)_relationships removeObject: relationship];
_relationships = [[_relationships autorelease] copy]; _relationships = [[GCArray alloc] initWithArray:[_relationships autorelease] copyItems:NO];
} }
[self _setIsEdited];//To clean caches [self _setIsEdited];//To clean caches
} }
@ -2092,17 +2111,21 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
@selector(compare:)]); @selector(compare:)]);
} }
- (void)setClassName:(NSString *)name - (void)_setClassName:(NSString *)name
{ {
//OK
[self willChange];
if (!name) if (!name)
{ {
NSLog(@"Entity %@ has no class name. Use EOGenericRecord", [self name]); NSLog(@"Entity %@ has no class name. Use EOGenericRecord", [self name]);
name = @"EOGenericRecord"; name = @"EOGenericRecord";
} }
ASSIGN(_className, name); ASSIGN(_className, name);
}
- (void)setClassName:(NSString *)name
{
//OK
[self willChange];
[self _setClassName:name];
[self _setIsEdited]; [self _setIsEdited];
} }
@ -2560,8 +2583,8 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
if (!_classDescription) if (!_classDescription)
{ {
_classDescription = [[EOEntityClassDescription _classDescription = RETAIN([EOEntityClassDescription
entityClassDescriptionWithEntity: self] retain]; entityClassDescriptionWithEntity: self]);
//NO ? NotifyCenter addObserver:EOEntityClassDescription selector:_eoNowMultiThreaded: name:NSWillBecomeMultiThreadedNotification object:nil //NO ? NotifyCenter addObserver:EOEntityClassDescription selector:_eoNowMultiThreaded: name:NSWillBecomeMultiThreadedNotification object:nil
} }
@ -2587,13 +2610,13 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
if (_flags.createsMutableObjects) if (_flags.createsMutableObjects)
{ {
_attributes = [[_attributes autorelease] mutableCopy]; _attributes = [[GCMutableArray alloc] initWithArray:[_attributes autorelease] copyItems:NO];
_relationships = [[_relationships autorelease] mutableCopy]; _relationships = [[GCMutableArray alloc] initWithArray:[_relationships autorelease] copyItems:NO];
} }
else else
{ {
_attributes = [[_attributes autorelease] copy]; _attributes = [[GCArray alloc] initWithArray:[_attributes autorelease] copyItems:NO];
_relationships = [[_relationships autorelease] copy]; _relationships = [[GCArray alloc] initWithArray:[_relationships autorelease] copyItems:NO];
} }
NSAssert4(!_attributesToFetch NSAssert4(!_attributesToFetch
@ -3097,7 +3120,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
[self classProperties], [self classProperties],
[self relationships] }; [self relationships] };
_attributesToFetch = [[GCMutableArray array] retain]; _attributesToFetch = RETAIN([GCMutableArray array]);
EOFLOGObjectLevelArgs(@"EOEntity", @"Entity %@ - _attributesToFetch %p [RC=%d]:%@", EOFLOGObjectLevelArgs(@"EOEntity", @"Entity %@ - _attributesToFetch %p [RC=%d]:%@",
[self name], [self name],
@ -3327,6 +3350,9 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
#define AUTORELEASE_SETNIL(v) { AUTORELEASE(v); v=nil; } #define AUTORELEASE_SETNIL(v) { AUTORELEASE(v); v=nil; }
- (void) _setIsEdited - (void) _setIsEdited
{ {
if(_flags.updating)
return;
EOFLOGObjectLevelArgs(@"EOEntity", @"START entity name=%@", [self name]); EOFLOGObjectLevelArgs(@"EOEntity", @"START entity name=%@", [self name]);
NSAssert4(!_attributesToFetch NSAssert4(!_attributesToFetch
@ -3801,7 +3827,7 @@ toDestinationAttributeInLastComponentOfRelationshipPath: (NSString*)path
} }
NS_HANDLER NS_HANDLER
{ {
[localException retain]; RETAIN(localException);
NSLog(@"exception in EOEntity _parseDescription:isFormat:arguments:"); NSLog(@"exception in EOEntity _parseDescription:isFormat:arguments:");
NSLog(@"exception=%@", localException); NSLog(@"exception=%@", localException);
@ -4126,6 +4152,7 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
} }
else //?? else //??
{ {
#if 0
BOOL propagatesPrimaryKey = [relationship propagatesPrimaryKey]; BOOL propagatesPrimaryKey = [relationship propagatesPrimaryKey];
if (propagatesPrimaryKey) if (propagatesPrimaryKey)
@ -4210,6 +4237,28 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
} }
} }
} }
#else
if ([relationship isMandatory])
{
id objectTo = [object storedValueForKey: [relationship name]];
if (objectTo == nil)
{
EOEntity *entityTo;
entityTo = [relationship destinationEntity];
objectTo = [[entityTo classDescriptionForInstances]
createInstanceWithEditingContext:
anEditingContext
globalID: nil
zone: NULL];
[anEditingContext insertObject: objectTo];
[object addObject: objectTo
toBothSidesOfRelationshipWithKey:
[relationship name]];
}
}
#endif
} }
} }
} }

View file

@ -36,6 +36,8 @@
RCS_ID("$Id$") RCS_ID("$Id$")
#include <gnustep/base/GSObjCRuntime.h>
#import <Foundation/NSBundle.h> #import <Foundation/NSBundle.h>
#import <Foundation/NSValue.h> #import <Foundation/NSValue.h>
#import <Foundation/NSUtilities.h> #import <Foundation/NSUtilities.h>
@ -44,6 +46,7 @@ RCS_ID("$Id$")
#import <Foundation/NSFileManager.h> #import <Foundation/NSFileManager.h>
#import <Foundation/NSValue.h> #import <Foundation/NSValue.h>
#import <Foundation/NSNotification.h> #import <Foundation/NSNotification.h>
#import <Foundation/NSPathUtilities.h>
#import <Foundation/NSDebug.h> #import <Foundation/NSDebug.h>
#import <EOAccess/EOModel.h> #import <EOAccess/EOModel.h>
@ -89,10 +92,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
NSString *tmpModelName = nil; NSString *tmpModelName = nil;
NSString *tmpPath = nil; NSString *tmpPath = nil;
NSBundle *bundle = nil; NSBundle *bundle = nil;
NSString *paths[] = { @"~/Library/Models", NSArray *paths = NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory, NSAllDomainsMask, YES);
@"/LocalLibrary/Models",
@"/NextLibrary/Models",
nil };
tmpModelName = [modelName lastPathComponent]; tmpModelName = [modelName lastPathComponent];
NSDebugMLLog(@"gsdb", @"modelName=%@ tmpModelName=%@", NSDebugMLLog(@"gsdb", @"modelName=%@ tmpModelName=%@",
@ -147,13 +147,13 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
if (!modelPath) if (!modelPath)
{ {
int i; int i, pathCount = [paths count];
for (i = 0; !modelPath && paths[i]; i++) for (i = 0; !modelPath && pathCount < i; i++)
{ {
NSDebugMLLog(@"gsdb", @"Trying path:%@", paths[i]); NSDebugMLLog(@"gsdb", @"Trying path:%@", [paths objectAtIndex:i]);
bundle = [NSBundle bundleWithPath: paths[i]]; bundle = [NSBundle bundleWithPath: [paths objectAtIndex:i]];
modelPath = [bundle pathForResource: modelName modelPath = [bundle pathForResource: modelName
ofType: @"eomodel"]; ofType: @"eomodel"];
@ -756,12 +756,11 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
_version = [[propertyList objectForKey: @"EOModelVersion"] _version = [[propertyList objectForKey: @"EOModelVersion"]
floatValue]; floatValue];
_adaptorName = [[propertyList objectForKey: @"adaptorName"] retain]; _adaptorName = RETAIN([propertyList objectForKey: @"adaptorName"]);
_connectionDictionary = [[propertyList objectForKey: _connectionDictionary = RETAIN([propertyList objectForKey:
@"connectionDictionary"] @"connectionDictionary"]);
retain]; _userInfo = RETAIN([propertyList objectForKey: @"userInfo"]);
_userInfo = [[propertyList objectForKey: @"userInfo"] retain]; _docComment = RETAIN([propertyList objectForKey: @"docComment"]);
_docComment = [[propertyList objectForKey: @"docComment"] retain];
propListEntities = [propertyList objectForKey: @"entities"]; propListEntities = [propertyList objectForKey: @"entities"];
propListSt = [propertyList objectForKey: @"storedProcedures"]; propListSt = [propertyList objectForKey: @"storedProcedures"];
@ -1351,10 +1350,10 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
[(GCMutableArray *)_storedProcedures addObject: storedProcedure]; [(GCMutableArray *)_storedProcedures addObject: storedProcedure];
else else
{ {
_storedProcedures = [[[_storedProcedures autorelease] mutableCopy] _storedProcedures = [[[GCMutableArray alloc] initWithArray:[_storedProcedures autorelease] copyItems:NO]
autorelease]; autorelease];
[(GCMutableArray *)_storedProcedures addObject: storedProcedure]; [(GCMutableArray *)_storedProcedures addObject: storedProcedure];
_storedProcedures = [_storedProcedures copy]; _storedProcedures = [[GCArray alloc] initWithArray:_storedProcedures copyItems:NO];
} }
} }
@ -1366,7 +1365,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
{ {
_storedProcedures = [[_storedProcedures autorelease] mutableCopy]; _storedProcedures = [[_storedProcedures autorelease] mutableCopy];
[(GCMutableArray *)_storedProcedures removeObject: storedProcedure]; [(GCMutableArray *)_storedProcedures removeObject: storedProcedure];
_storedProcedures = [[_storedProcedures autorelease] copy]; _storedProcedures = [[GCArray alloc] initWithArray:[_storedProcedures autorelease] copyItems:NO];
} }
} }
@ -1543,9 +1542,9 @@ letter of each embedded word other than the first, which is upper case. Thus,
_flags.createsMutableObjects = flag; _flags.createsMutableObjects = flag;
if (_flags.createsMutableObjects) if (_flags.createsMutableObjects)
_entities = [[_entities autorelease] mutableCopy]; _entities = [[GCMutableArray alloc] initWithArray:[_entities autorelease] copyItems:NO];
else else
_entities = [[_entities autorelease] copy]; _entities = [[GCArray alloc] initWithArray:[_entities autorelease] copyItems:NO];
} }
} }
@ -1577,7 +1576,7 @@ letter of each embedded word other than the first, which is upper case. Thus,
NSDebugMLLog(@"gsdb", @"[self path]=%@", [self path]); NSDebugMLLog(@"gsdb", @"[self path]=%@", [self path]);
basePath = [self path]; basePath = [self path];
[[entity retain] autorelease]; //so it won't be lost in _removeEntity [RETAIN(entity) autorelease]; //so it won't be lost in _removeEntity
NSDebugMLLog(@"gsdb", @"basePath =%@", basePath); NSDebugMLLog(@"gsdb", @"basePath =%@", basePath);

View file

@ -1474,10 +1474,10 @@ relationships. Nil if none" **/
else else
{ {
if (_joins) if (_joins)
_joins = [[[_joins autorelease] _joins = RETAIN([[_joins autorelease]
arrayByAddingObject: join] retain]; arrayByAddingObject: join]);
else else
_joins = [[GCArray arrayWithObject: join] retain]; _joins = RETAIN([GCArray arrayWithObject: join]);
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@", EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]); _joins, [_joins class]);
@ -1721,7 +1721,7 @@ becomes "name", and "FIRST_NAME" becomes "firstName".*/
} }
else else
{ {
_joins = [[_joins autorelease] copy]; _joins = [[GCArray alloc] initWithArray:[_joins autorelease] copyItems:NO];
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@", EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]); _joins, [_joins class]);

View file

@ -75,6 +75,10 @@ NSString *EOBindVariablePlaceHolderKey = @"EOBindVariablePlaceHolderKey";
NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey"; NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
@interface EOSQLExpression(Private)
+ (id)sqlExpressionWithEntity: (EOEntity *)entity;
@end
@implementation EOSQLExpression @implementation EOSQLExpression
+ (id)sqlExpressionWithEntity: (EOEntity *)entity + (id)sqlExpressionWithEntity: (EOEntity *)entity
@ -2343,6 +2347,7 @@ All relationshipPaths in _aliasesByRelationshipPath are direct paths **/
return [self stringValue]; return [self stringValue];
} }
@end
@implementation NSObject (EOSQLFormatting) @implementation NSObject (EOSQLFormatting)
@ -2419,6 +2424,52 @@ NSString *EODropDatabaseKey = @"EODropDatabaseKey";
return array; return array;
} }
+ (NSArray *)foreignKeyConstraintStatementsForEntityGroup:(NSArray *)entityGroup
{
NSMutableArray *sqlExps;
NSEnumerator *relEnum;
EORelationship *rel;
EOEntity *entity;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
entity = [entityGroup objectAtIndex: 0];
sqlExps = [NSMutableArray array];
relEnum = [[entity relationships] objectEnumerator];
while ((rel = [relEnum nextObject]))
{
[sqlExps addObjectsFromArray:
[self foreignKeyConstraintStatementsForRelationship: rel]];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return sqlExps;
}
+ (NSArray *)foreignKeyConstraintStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
[array addObjectsFromArray:
[self foreignKeyConstraintStatementsForEntityGroup: group]];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
// default implementation verifies that relationship joins on foreign key // default implementation verifies that relationship joins on foreign key
// of destination and calls // of destination and calls
// prepareConstraintStatementForRelationship:sourceColumns:destinationColumns: // prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:
@ -2445,7 +2496,7 @@ NSString *EODropDatabaseKey = @"EODropDatabaseKey";
[sqlExp setStatement: [NSString stringWithFormat:@"CREATE TABLE %@ (%@)", [sqlExp setStatement: [NSString stringWithFormat:@"CREATE TABLE %@ (%@)",
[[entityGroup objectAtIndex: 0] externalName], [[entityGroup objectAtIndex: 0] externalName],
[self listString]]]; [sqlExp listString]]];
EOFLOGClassFnStopOrCond(@"EOSQLExpression"); EOFLOGClassFnStopOrCond(@"EOSQLExpression");
@ -2717,20 +2768,20 @@ struct _schema
EOEntity *entity; EOEntity *entity;
int i, h, count; int i, h, count;
struct _schema defaults[] = { struct _schema defaults[] = {
{EOCreateTablesKey , @"YES",
@selector(createTableStatementsForEntityGroups:)},
{EODropTablesKey , @"YES",
@selector(dropTableStatementsForEntityGroups:)},
{EOCreatePrimaryKeySupportKey, @"YES",
@selector(primaryKeySupportStatementsForEntityGroups:)},
{EODropPrimaryKeySupportKey , @"YES", {EODropPrimaryKeySupportKey , @"YES",
@selector(dropPrimaryKeySupportStatementsForEntityGroups:)}, @selector(dropPrimaryKeySupportStatementsForEntityGroups:)},
{EODropTablesKey , @"YES",
@selector(dropTableStatementsForEntityGroups:)},
{EOCreateTablesKey , @"YES",
@selector(createTableStatementsForEntityGroups:)},
{EOCreatePrimaryKeySupportKey, @"YES",
@selector(primaryKeySupportStatementsForEntityGroups:)},
{EOPrimaryKeyContraintsKey , @"YES", {EOPrimaryKeyContraintsKey , @"YES",
@selector(primaryKeyConstraintStatementsForEntityGroups:)}, @selector(primaryKeyConstraintStatementsForEntityGroups:)},
{EOForeignKeyConstraintsKey , @"NO", {EOForeignKeyConstraintsKey , @"NO",
@selector(foreignKeyConstraintStatementsForRelationship:)}, @selector(foreignKeyConstraintStatementsForEntityGroups:)},
{nil, nil}, {nil, nil},
}; }; // Order is important!
EOFLOGClassFnStartOrCond(@"EOSQLExpression"); EOFLOGClassFnStartOrCond(@"EOSQLExpression");
@ -2779,7 +2830,6 @@ struct _schema
{ {
NSString *extType = [attribute externalType]; NSString *extType = [attribute externalType];
int precision = [attribute precision]; int precision = [attribute precision];
int scale = [attribute scale];
EOFLOGClassFnStartOrCond(@"EOSQLExpression"); EOFLOGClassFnStartOrCond(@"EOSQLExpression");
@ -2787,12 +2837,12 @@ struct _schema
{ {
EOFLOGClassFnStopOrCond(@"EOSQLExpression"); EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSString stringWithFormat:@"%@(%d, %d)", extType, precision, return [NSString stringWithFormat:@"%@(%d, %d)", extType, precision,
scale]; [attribute scale]];
} }
else if ([attribute width]) else if ([attribute width])
{ {
EOFLOGClassFnStopOrCond(@"EOSQLExpression"); EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSString stringWithFormat: @"%@(%d)", extType, scale]; return [NSString stringWithFormat: @"%@(%d)", extType, [attribute width]];
} }
else else
{ {
@ -2825,9 +2875,9 @@ struct _schema
columnType, allowsNull]; columnType, allowsNull];
else else
str = [NSString stringWithFormat: @"%@ %@", [attribute columnName], str = [NSString stringWithFormat: @"%@ %@", [attribute columnName],
allowsNull]; columnType];
[self appendItem:str toListString: _listString]; [self appendItem:str toListString: /*_listString*/[self listString]]; // Else no chance to get inited (lazy)
EOFLOGClassFnStopOrCond(@"EOSQLExpression"); EOFLOGClassFnStopOrCond(@"EOSQLExpression");
} }

View file

@ -36,6 +36,7 @@
RCS_ID("$Id$") RCS_ID("$Id$")
#import <Foundation/NSException.h> #import <Foundation/NSException.h>
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSDebug.h> #import <Foundation/NSDebug.h>
#import <gnustep/base/GCObject.h> #import <gnustep/base/GCObject.h>
@ -99,7 +100,7 @@ RCS_ID("$Id$")
NSEnumerator *enumerator; NSEnumerator *enumerator;
id attributePList; id attributePList;
_model = [owner retain]; _model = RETAIN(owner);
[self setName: [propertyList objectForKey: @"name"]]; [self setName: [propertyList objectForKey: @"name"]];
[self setExternalName: [propertyList objectForKey: @"externalName"]]; [self setExternalName: [propertyList objectForKey: @"externalName"]];

View file

@ -74,8 +74,6 @@ extern NSString *EOMoreThanOneException;
- (id)objectWithPrimaryKey: (NSDictionary*)pkDict - (id)objectWithPrimaryKey: (NSDictionary*)pkDict
entityNamed: (NSString*)name; entityNamed: (NSString*)name;
- (NSArray *)objectsOfClass: (Class)class;
- (NSArray*)rawRowsForEntityNamed: (NSString*)name - (NSArray*)rawRowsForEntityNamed: (NSString*)name
qualifierFormat: (NSString*)format, ...; qualifierFormat: (NSString*)format, ...;
- (NSArray*)rawRowsMatchingValue: (id)value - (NSArray*)rawRowsMatchingValue: (id)value

View file

@ -41,6 +41,7 @@ RCS_ID("$Id$")
#import <EOControl/EOQualifier.h> #import <EOControl/EOQualifier.h>
#import <EOControl/EOFetchSpecification.h> #import <EOControl/EOFetchSpecification.h>
#import <EOControl/EONull.h> #import <EOControl/EONull.h>
#import <EOControl/EOGenericRecord.h>
#import <EOControl/EODebug.h> #import <EOControl/EODebug.h>
#import <EOAccess/EOAccess.h> #import <EOAccess/EOAccess.h>
@ -228,7 +229,7 @@ static NSString *EOMoreThanOneException = @"EOMoreThanOneException";
} }
NS_HANDLER NS_HANDLER
{ {
NSDebugMLog(@"exception in EOEditingContext (EOUtilities) objectsMatchingValues:entityNamed:"); NSDebugMLog(@"exception in EOEditingContext (EOUtilities) objectsMatchingValues:entityNamed:", "");
NSLog(@"exception in EOEditingContext (EOUtilities) objectsMatchingValues:entityNamed:"); NSLog(@"exception in EOEditingContext (EOUtilities) objectsMatchingValues:entityNamed:");
NSDebugMLog(@"exception=%@", localException); NSDebugMLog(@"exception=%@", localException);
NSLog(@"exception=%@", localException); NSLog(@"exception=%@", localException);
@ -1024,7 +1025,7 @@ connectionDictionaryOverrides: (NSDictionary *)overrides
EOFLOGObjectFnStartOrCond(@"EOEditingContext"); EOFLOGObjectFnStartOrCond(@"EOEditingContext");
classDesc = (EOClassDescription *)[object classDescription]; classDesc = [(EOGenericRecord *)object classDescription];
if ([classDesc isKindOfClass: [EOEntityClassDescription class]] == NO) if ([classDesc isKindOfClass: [EOEntityClassDescription class]] == NO)
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
@ -1096,7 +1097,7 @@ connectionDictionaryOverrides: (NSDictionary *)overrides
EOFLOGObjectFnStart(); EOFLOGObjectFnStart();
userInfo = [self userInfo]; userInfo = (NSMutableDictionary *)[self userInfo];
if (userInfo) if (userInfo)
[userInfo setObject: modelGroup [userInfo setObject: modelGroup

View file

@ -149,26 +149,27 @@ static int pgConnCurrentAllocated = 0;
}*/ }*/
static NSString *externalTypeNames[] = { static NSString *externalTypeNames[] = {
@"bool", #warning (stephane@sente.ch) Needs to be updated!!!
@"boolean", @"bool",
@"char", @"char2", @"char4", @"char8", @"char16", @"filename", @"char", @"char2", @"char4", @"char8", @"char16", @"filename",
@"date", @"reltime", @"time", @"tinterval", @"abstime", @"date", @"reltime", @"time", @"tinterval", @"abstime", @"timestamp",
@"float4", @"float8", @"real", @"double precision", @"float4", @"float8",
@"int4", @"int2", @"int4", @"int2",
@"oid", @"oid8", @"oidint2", @"oidint4", @"oidchar16", @"oid", @"oid8", @"oidint2", @"oidint4", @"oidchar16",
@"varchar", @"bpchar", @"varchar", @"bpchar",
@"cid", @"tid", @"xid", @"numeric", @"decimal", @"cid", @"tid", @"xid",
nil nil
}; };
static NSString *internalTypeNames[] = { static NSString *internalTypeNames[] = {
@"NSNumber",
@"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber",
@"NSCalendarDate", @"NSCalendarDate", @"NSCalendarDate", @"NSCalendarDate", @"NSCalendarDate",
@"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber",
@"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber",
@"NSCalendarDate", @"NSCalendarDate", @"NSCalendarDate", @"NSCalendarDate", @"NSCalendarDate", @"NSCalendarDate",
@"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber",
@"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber",
@"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber", @"NSNumber",
@"NSString", @"NSString", @"NSString", @"NSString",
@"NSDecimalNumber", @"NSDecimalNumber", @"NSDecimalNumber", @"NSDecimalNumber", @"NSDecimalNumber", @"NSDecimalNumber", @"NSDecimalNumber", @"NSDecimalNumber",
nil nil
}; };
@ -182,7 +183,7 @@ static NSString *internalTypeNames[] = {
for (i = 0; externalTypeNames[i]; i++); for (i = 0; externalTypeNames[i]; i++);
externalToInternalTypeMap = [[NSDictionary dictionaryWithObjects: internalTypeNames forKeys: externalTypeNames count: i] retain]; externalToInternalTypeMap = [[NSDictionary alloc] initWithObjects: internalTypeNames forKeys: externalTypeNames count: i];
} }
return externalToInternalTypeMap; return externalToInternalTypeMap;

View file

@ -82,13 +82,14 @@ static void __dummy_function_used_for_linking(void)
//verify //verify
_oidToTypeName = [[NSMutableDictionary alloc] initWithCapacity: 101]; _oidToTypeName = [[NSMutableDictionary alloc] initWithCapacity: 101];
attr = [[[EOAttribute alloc] init] autorelease]; attr = [[EOAttribute alloc] init];
[attr setName: @"nextval"]; [attr setName: @"nextval"];
[attr setColumnName: @"nextval"]; [attr setColumnName: @"nextval"];
[attr setValueType: @"i"]; [attr setValueType: @"i"];
[attr setValueClassName: @"NSNumber"]; [attr setValueClassName: @"NSNumber"];
ASSIGN(_pkAttributeArray, [NSArray arrayWithObject: attr]); ASSIGN(_pkAttributeArray, [NSArray arrayWithObject: attr]);
RELEASE(attr);
} }
return self; return self;
@ -261,7 +262,7 @@ zone:zone
if ([self advanceRow] == NO) if ([self advanceRow] == NO)
{ {
NSDebugMLLog(@"gsdb", @"No Advance Row"); NSDebugMLLog(@"gsdb", @"No Advance Row", "");
// Return nil to indicate that the fetch operation was finished // Return nil to indicate that the fetch operation was finished
if (_delegateRespondsTo.didFinishFetching) if (_delegateRespondsTo.didFinishFetching)
@ -307,7 +308,7 @@ zone:zone
if (PQgetisnull(_pgResult, _currentResultRow, i)) if (PQgetisnull(_pgResult, _currentResultRow, i))
{ {
values[i] = [nullValue retain]; //to be compatible with others returned values values[i] = RETAIN(nullValue); //to be compatible with others returned values
} }
else else
{ {
@ -511,7 +512,7 @@ zone:zone
//call PostgreSQLChannel numberOfAffectedRows //call PostgreSQLChannel numberOfAffectedRows
/* Send the expression to the SQL server */ /* Send the expression to the SQL server */
_pgResult = PQexec(_pgConn, (char *)[[expression statement] cString]); _pgResult = PQexec(_pgConn, (char *)[[[expression statement] stringByAppendingString:@";"] cString]); // stephane@sente.ch: We need to add ; for INSERT, at least
NSDebugMLLog(@"gsdb", @"_pgResult=%p", (void*)_pgResult); NSDebugMLLog(@"gsdb", @"_pgResult=%p", (void*)_pgResult);
if (_pgResult == NULL) if (_pgResult == NULL)
@ -575,7 +576,7 @@ zone:zone
if (![self _evaluateExpression: expression if (![self _evaluateExpression: expression
withAttributes: nil]) withAttributes: nil])
{ {
NSDebugMLLog(@"gsdb", @"_evaluateExpression:withAttributes: return NO"); NSDebugMLLog(@"gsdb", @"_evaluateExpression:withAttributes: return NO", "");
[self _cancelResults]; [self _cancelResults];
} }
else else
@ -630,13 +631,13 @@ zone:zone
row the large objects as Oids and to insert them with the large row the large objects as Oids and to insert them with the large
object file-like interface */ object file-like interface */
nrow = [[row mutableCopy] autorelease]; nrow = AUTORELEASE([row mutableCopy]);
adaptorContext = (Postgres95Context *)[self adaptorContext]; adaptorContext = (Postgres95Context *)[self adaptorContext];
[self _cancelResults]; //No done by WO [self _cancelResults]; //No done by WO
NSDebugMLLog(@"gsdb", @"autoBeginTransaction"); NSDebugMLLog(@"gsdb", @"autoBeginTransaction", "");
[adaptorContext autoBeginTransaction: YES]; [adaptorContext autoBeginTransaction: YES];
/*: /*:
row allKeys row allKeys
@ -840,10 +841,10 @@ each key
[self _evaluateExpression: sqlExpr [self _evaluateExpression: sqlExpr
withAttributes: attributes]; withAttributes: attributes];
NSDebugMLLog(@"gsdb", @"After _evaluate"); NSDebugMLLog(@"gsdb", @"After _evaluate", "");
// NSDebugMLLog(@"gsdb",@"BB attributes=%@",_attributes); // NSDebugMLLog(@"gsdb",@"BB attributes=%@",_attributes);
[_adaptorContext autoCommitTransaction]; [_adaptorContext autoCommitTransaction];
NSDebugMLLog(@"gsdb", @"After autoCommitTransaction"); NSDebugMLLog(@"gsdb", @"After autoCommitTransaction", "");
if (_delegateRespondsTo.didSelectAttributes) if (_delegateRespondsTo.didSelectAttributes)
[_delegate adaptorChannel: self [_delegate adaptorChannel: self
@ -900,13 +901,12 @@ each key
if ([values count] > 0) if ([values count] > 0)
{ {
mrow = [[values mutableCopyWithZone: [values zone]] autorelease]; mrow = AUTORELEASE([values mutableCopyWithZone: [values zone]]);
// Get EOAttributes involved in update operation // Get EOAttributes involved in update operation
// Modify "inversion" attributes to NSNumber type with the Oid // Modify "inversion" attributes to NSNumber type with the Oid
invAttributes = [[[NSMutableArray alloc] initWithCapacity: [mrow count]] invAttributes = AUTORELEASE([[NSMutableArray alloc] initWithCapacity: [mrow count]]);
autorelease];
enumerator = [values keyEnumerator]; enumerator = [values keyEnumerator];
while ((attrName = [enumerator nextObject])) while ((attrName = [enumerator nextObject]))
@ -1219,7 +1219,7 @@ each key
for (i = 0; i < colsNumber; i++) for (i = 0; i < colsNumber; i++)
{ {
EOAttribute *attribute = [[EOAttribute new] autorelease]; EOAttribute *attribute = AUTORELEASE([EOAttribute new]);
NSString *externalName; NSString *externalName;
NSString *valueClass = @"NSString"; NSString *valueClass = @"NSString";
NSString *valueType = nil; NSString *valueType = nil;
@ -1296,9 +1296,9 @@ each key
[[attribute entity] attributesToFetch]); [[attribute entity] attributesToFetch]);
} }
[self setAttributesToFetch: [[[NSArray alloc] [self setAttributesToFetch: AUTORELEASE([[NSArray alloc]
initWithObjects: attributes initWithObjects: attributes
count: colsNumber] autorelease]]; count: colsNumber])];
} }
// NSDebugMLLog(@"gsdb",@"_attributes=%@",_attributes); // NSDebugMLLog(@"gsdb",@"_attributes=%@",_attributes);
@ -1316,8 +1316,7 @@ each key
NSAssert(_pgConn, @"Channel not opened"); NSAssert(_pgConn, @"Channel not opened");
_pgResult = PQexec(_pgConn, _pgResult = PQexec(_pgConn,
"SELECT tablename FROM pg_tables WHERE "SELECT tablename FROM pg_tables WHERE pg_tables.schemaname = 'public'");
pg_tables.schemaname = 'public'");
if (_pgResult == NULL if (_pgResult == NULL
|| PQresultStatus(_pgResult) != PGRES_TUPLES_OK) || PQresultStatus(_pgResult) != PGRES_TUPLES_OK)
@ -1358,13 +1357,13 @@ pg_tables.schemaname = 'public'");
EOModel *model; EOModel *model;
EOEntity *entity; EOEntity *entity;
model = [[[EOModel alloc] init] autorelease]; model = AUTORELEASE([[EOModel alloc] init]);
tableEnum = [tableNames objectEnumerator]; tableEnum = [tableNames objectEnumerator];
while ((table = [tableEnum nextObject])) while ((table = [tableEnum nextObject]))
{ {
entity = [[[EOEntity alloc] init] autorelease]; entity = AUTORELEASE([[EOEntity alloc] init]);
[entity setExternalName: table]; [entity setExternalName: table];
[model addEntity: entity]; [model addEntity: entity];
} }
@ -1431,11 +1430,10 @@ pg_tables.schemaname = 'public'");
string = PQgetvalue(_pgResult, _currentResultRow, 0); string = PQgetvalue(_pgResult, _currentResultRow, 0);
length = PQgetlength(_pgResult, _currentResultRow, 0); length = PQgetlength(_pgResult, _currentResultRow, 0);
pkValue = [[Postgres95Values newValueForBytes: string pkValue = AUTORELEASE([Postgres95Values newValueForBytes: string
length: length length: length
attribute: [_pkAttributeArray attribute: [_pkAttributeArray
objectAtIndex: 0]] objectAtIndex: 0]]);
autorelease];
NSAssert(pkValue, @"no pk value"); NSAssert(pkValue, @"no pk value");
key = [[entity primaryKeyAttributeNames] objectAtIndex: 0]; key = [[entity primaryKeyAttributeNames] objectAtIndex: 0];

View file

@ -40,7 +40,9 @@ RCS_ID("$Id$")
#import <Foundation/NSUtilities.h> #import <Foundation/NSUtilities.h>
#import <Foundation/NSException.h> #import <Foundation/NSException.h>
#import <EOAccess/EOAccess.h> #import <EOAccess/EOAttribute.h>
#import <EOAccess/EOEntity.h>
#import <EOAccess/EOSchemaGeneration.h>
#import <EOControl/EODebug.h> #import <EOControl/EODebug.h>
@ -167,7 +169,7 @@ RCS_ID("$Id$")
formatted = @"NULL"; formatted = @"NULL";
} }
else if (([externalType isEqualToString: @"abstime"]) else if (([externalType isEqualToString: @"abstime"])
|| ([externalType isEqualToString: @"datetime"]) /*|| ([externalType isEqualToString: @"datetime"])*//* stephane@sente.ch: datetime does not exist */
|| ([externalType isEqualToString: @"timestamp"])) || ([externalType isEqualToString: @"timestamp"]))
{ {
EOFLOGObjectLevelArgs(@"EOSQLExpression", EOFLOGObjectLevelArgs(@"EOSQLExpression",
@ -210,7 +212,7 @@ RCS_ID("$Id$")
for (i = 0, dif = 0; i < length; i++) for (i = 0, dif = 0; i < length; i++)
{ {
switch (tempString[i]) switch (tempString[i + dif])
{ {
case '\\': case '\\':
case '\'': case '\'':
@ -298,5 +300,37 @@ RCS_ID("$Id$")
} }
@end + (NSArray *)dropTableStatementsForEntityGroup:(NSArray *)entityGroup
{
// We redefine this method to add the CASCADE: it is needed to delete
// associated foreign key constraints when dropping a table.
// Q: shouldn't we move this into EOSQLExpression.m?
NSArray *newArray = nil;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
newArray = [NSArray arrayWithObject:
[self expressionForString:
[NSString stringWithFormat: @"DROP TABLE %@ CASCADE",
[[entityGroup objectAtIndex: 0]
externalName]]]];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return newArray;
}
- (void)prepareConstraintStatementForRelationship: (EORelationship *)relationship
sourceColumns: (NSArray *)sourceColumns
destinationColumns: (NSArray *)destinationColumns
{
// We redefine this method to add "DEFERRABLE INITIALLY DEFERRED": it is needed
// to be able to insert rows into table related to other table rows, before these
// other rows have been inserted (relationship might be bidirectional, or it might
// simply be an operation order problem)
// Q: shouldn't we move this into EOSQLExpression.m?
[super prepareConstraintStatementForRelationship:relationship sourceColumns:sourceColumns destinationColumns:destinationColumns];
ASSIGN(_statement, [_statement stringByAppendingString:@" DEFERRABLE INITIALLY DEFERRED"]);
}
@end

View file

@ -43,7 +43,7 @@
extern NSString *Postgres95CalendarFormat; extern NSString *Postgres95CalendarFormat;
@interface Postgres95Values @interface Postgres95Values:NSObject
{ {
} }

View file

@ -95,8 +95,7 @@ For efficiency reasons, the returned value is NOT autoreleased !
length: (int)length length: (int)length
attribute: (EOAttribute *)attribute attribute: (EOAttribute *)attribute
{ {
NSString *str = [NSString stringWithCString:(char *)bytes NSString *str = nil;
length:length];
id value = nil; id value = nil;
if ([[attribute externalType] isEqualToString: @"bool"]) if ([[attribute externalType] isEqualToString: @"bool"])
@ -107,13 +106,17 @@ For efficiency reasons, the returned value is NOT autoreleased !
return [[NSNumber alloc] initWithBool:NO]; return [[NSNumber alloc] initWithBool:NO];
} }
str = [[NSString alloc] initWithCString:(char *)bytes length:length];
if ([[attribute valueClassName] isEqualToString: @"NSDecimalNumber"]) if ([[attribute valueClassName] isEqualToString: @"NSDecimalNumber"])
value = [[NSDecimalNumber decimalNumberWithString: str] retain]; value = [[NSDecimalNumber alloc] initWithString: str];
else if ([[attribute valueType] isEqualToString: @"i"]) else if ([[attribute valueType] isEqualToString: @"i"])
value = [[NSNumber alloc] initWithInt: [str intValue]]; value = [[NSNumber alloc] initWithInt: [str intValue]];
else else
value = [[NSNumber alloc] initWithDouble: [str doubleValue]]; value = [[NSNumber alloc] initWithDouble: [str doubleValue]];
[str release];
return value; return value;
} }
@ -152,10 +155,9 @@ For efficiency reasons, the returned value is NOT autoreleased !
NSString *str = [NSString stringWithCString: bytes length: length]; NSString *str = [NSString stringWithCString: bytes length: length];
NSString *format = [NSCalendarDate postgres95Format]; NSString *format = [NSCalendarDate postgres95Format];
d = [[[NSCalendarDate alloc] initWithString: str d = [[NSCalendarDate alloc] initWithString: str
calendarFormat: format] calendarFormat: format];
// TODO server TZ ? // TODO server TZ ?
retain];
// NSDebugMLLog(@"gsdb",@"str=%@ d=%@ format=%@",str,d,format); // NSDebugMLLog(@"gsdb",@"str=%@ d=%@ format=%@",str,d,format);
NSDebugMLog(@"str=%@ d=%@ format=%@", str, d, format); NSDebugMLog(@"str=%@ d=%@ format=%@", str, d, format);