mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-06-03 02:31:00 +00:00
* EOAccess/EOAccessFault.h/m: Minor cleanups for autogsdoc.
* EOAccess/EOAdaptor.m: Ditto. * EOAccess/EOAdaptorChannel.h/m: Ditto. * EOAccess/EOAdaptorContext.h: Ditto. * EOAccess/EODatabase.h/m: Ditto. * EOAccess/EODatabaseChannel.m: Ditto. * EOAccess/EODatabaseContext.h/m: Ditto. * EOAccess/EODatabaseDataSource.h: Ditto. * EOAccess/EODatabaseOperation.h: Ditto. * EOAccess/EOEntity.h/m: Ditto. * EOAccess/EOModel.h/m: Ditto. * EOAccess/EORelationship.h: Ditto. * EOAccess/EOSchemaGeneration.h: Ditto. * EOAccess/EOUtilities.h/m: Ditto. * EOAccess/EOSQLExpression.h/m: Minor cleanups for autogsdoc. (EOSchemaGeneration): Move implementation from here to ... * EOAccess/EOSchemaGeneration.m: ... new file for autogsdoc. * EOAccess/GNUmakefile: Add EOSchemaGeneration.m. * EOAccess/EOUtilities.m (EOObjectStoreCoordinator EOModelGroup): Move implementation from here to ... * EOAccess/EOModelGroup.m: ... to here for autogsdoc. * common.make: (GDL2_AGSDOC_FLAGS): Add extern declarations. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@24302 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
97111db765
commit
c4bf6fba06
28 changed files with 1157 additions and 1047 deletions
28
ChangeLog
28
ChangeLog
|
@ -1,3 +1,31 @@
|
||||||
|
2007-01-01 David Ayers <ayers@fsfe.org>
|
||||||
|
|
||||||
|
* EOAccess/EOAccessFault.h/m: Minor cleanups for autogsdoc.
|
||||||
|
* EOAccess/EOAdaptor.m: Ditto.
|
||||||
|
* EOAccess/EOAdaptorChannel.h/m: Ditto.
|
||||||
|
* EOAccess/EOAdaptorContext.h: Ditto.
|
||||||
|
* EOAccess/EODatabase.h/m: Ditto.
|
||||||
|
* EOAccess/EODatabaseChannel.m: Ditto.
|
||||||
|
* EOAccess/EODatabaseContext.h/m: Ditto.
|
||||||
|
* EOAccess/EODatabaseDataSource.h: Ditto.
|
||||||
|
* EOAccess/EODatabaseOperation.h: Ditto.
|
||||||
|
* EOAccess/EOEntity.h/m: Ditto.
|
||||||
|
* EOAccess/EOModel.h/m: Ditto.
|
||||||
|
* EOAccess/EORelationship.h: Ditto.
|
||||||
|
* EOAccess/EOSchemaGeneration.h: Ditto.
|
||||||
|
* EOAccess/EOUtilities.h/m: Ditto.
|
||||||
|
|
||||||
|
* EOAccess/EOSQLExpression.h/m: Minor cleanups for autogsdoc.
|
||||||
|
(EOSchemaGeneration): Move implementation from here to ...
|
||||||
|
* EOAccess/EOSchemaGeneration.m: ... new file for autogsdoc.
|
||||||
|
* EOAccess/GNUmakefile: Add EOSchemaGeneration.m.
|
||||||
|
|
||||||
|
* EOAccess/EOUtilities.m (EOObjectStoreCoordinator EOModelGroup):
|
||||||
|
Move implementation from here to ...
|
||||||
|
* EOAccess/EOModelGroup.m: ... to here for autogsdoc.
|
||||||
|
|
||||||
|
* common.make: (GDL2_AGSDOC_FLAGS): Add extern declarations.
|
||||||
|
|
||||||
2006-12-31 David Ayers <ayers@fsfe.org>
|
2006-12-31 David Ayers <ayers@fsfe.org>
|
||||||
|
|
||||||
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLValues.h/m:
|
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLValues.h/m:
|
||||||
|
|
|
@ -87,12 +87,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (EOAccessArrayFaultHandler *)accessArrayFaultHandlerWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
|
+ (EOAccessArrayFaultHandler *)accessArrayFaultHandlerWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
|
||||||
relationshipName: (NSString *)relationshipName
|
relationshipName: (NSString *)relName
|
||||||
databaseContext: (EODatabaseContext *)dbcontext
|
databaseContext: (EODatabaseContext *)dbcontext
|
||||||
editingContext: (EOEditingContext *)ec;
|
editingContext: (EOEditingContext *)ec;
|
||||||
|
|
||||||
- (id)initWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
|
- (id)initWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
|
||||||
relationshipName: (NSString *)relationshipName
|
relationshipName: (NSString *)relName
|
||||||
databaseContext: (EODatabaseContext *)dbcontext
|
databaseContext: (EODatabaseContext *)dbcontext
|
||||||
editingContext: (EOEditingContext *)ec;
|
editingContext: (EOEditingContext *)ec;
|
||||||
|
|
||||||
|
|
|
@ -285,12 +285,12 @@ NSString *EOAccessFaultObjectNotAvailableException = @"EOAccessFaultObjectNotAva
|
||||||
@implementation EOAccessArrayFaultHandler
|
@implementation EOAccessArrayFaultHandler
|
||||||
|
|
||||||
+ (EOAccessArrayFaultHandler *)accessArrayFaultHandlerWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
|
+ (EOAccessArrayFaultHandler *)accessArrayFaultHandlerWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
|
||||||
relationshipName: (NSString *)aRelationshipName
|
relationshipName: (NSString *)relName
|
||||||
databaseContext: (EODatabaseContext *)dbcontext
|
databaseContext: (EODatabaseContext *)dbcontext
|
||||||
editingContext: (EOEditingContext *)ec
|
editingContext: (EOEditingContext *)ec
|
||||||
{
|
{
|
||||||
return [[[self alloc] initWithSourceGlobalID: sourceGID
|
return [[[self alloc] initWithSourceGlobalID: sourceGID
|
||||||
relationshipName: aRelationshipName
|
relationshipName: relName
|
||||||
databaseContext: dbcontext
|
databaseContext: dbcontext
|
||||||
editingContext: ec] autorelease];
|
editingContext: ec] autorelease];
|
||||||
}
|
}
|
||||||
|
@ -304,10 +304,10 @@ NSString *EOAccessFaultObjectNotAvailableException = @"EOAccessFaultObjectNotAva
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
|
- (id)initWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
|
||||||
relationshipName: (NSString *)relName
|
relationshipName: (NSString *)relName
|
||||||
databaseContext: (EODatabaseContext *)dbcontext
|
databaseContext: (EODatabaseContext *)dbcontext
|
||||||
editingContext: (EOEditingContext *)ec
|
editingContext: (EOEditingContext *)ec
|
||||||
{
|
{
|
||||||
if ((self = [self init]))
|
if ((self = [self init]))
|
||||||
{
|
{
|
||||||
|
|
|
@ -184,7 +184,7 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
|
||||||
return adaptor;
|
return adaptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id) adaptorWithName: (NSString *)adaptorName
|
+ (id) adaptorWithName: (NSString *)name
|
||||||
{
|
{
|
||||||
//OK
|
//OK
|
||||||
NSBundle *bundle = [NSBundle mainBundle];
|
NSBundle *bundle = [NSBundle mainBundle];
|
||||||
|
@ -195,7 +195,7 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
|
||||||
unsigned i, count;
|
unsigned i, count;
|
||||||
|
|
||||||
/* Check error */
|
/* Check error */
|
||||||
if ([adaptorName length] == 0)
|
if ([name length] == 0)
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"%@ -- %@ 0x%x: adaptor name can't be nil",
|
format: @"%@ -- %@ 0x%x: adaptor name can't be nil",
|
||||||
NSStringFromSelector(_cmd),
|
NSStringFromSelector(_cmd),
|
||||||
|
@ -203,11 +203,11 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
|
||||||
self];
|
self];
|
||||||
|
|
||||||
// append EOAdaptor
|
// append EOAdaptor
|
||||||
if ([adaptorName hasSuffix: @"EOAdaptor"] == NO)
|
if ([name hasSuffix: @"EOAdaptor"] == NO)
|
||||||
adaptorName = [adaptorName stringByAppendingString: @"EOAdaptor"];
|
name = [name stringByAppendingString: @"EOAdaptor"];
|
||||||
|
|
||||||
/* Look in application bundle */
|
/* Look in application bundle */
|
||||||
adaptorBundlePath = [bundle pathForResource: adaptorName
|
adaptorBundlePath = [bundle pathForResource: name
|
||||||
ofType: @"framework"];
|
ofType: @"framework"];
|
||||||
// should be NSString *path=[NSBundle pathForLibraryResource:libraryResource type:@"framework" directory:@"Frameworks"]; ?
|
// should be NSString *path=[NSBundle pathForLibraryResource:libraryResource type:@"framework" directory:@"Frameworks"]; ?
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
|
||||||
for(i = 0, count = [paths count]; i < count; i++)
|
for(i = 0, count = [paths count]; i < count; i++)
|
||||||
{
|
{
|
||||||
bundle = [NSBundle bundleWithPath: [paths objectAtIndex: i]];
|
bundle = [NSBundle bundleWithPath: [paths objectAtIndex: i]];
|
||||||
adaptorBundlePath = [bundle pathForResource: adaptorName
|
adaptorBundlePath = [bundle pathForResource: name
|
||||||
ofType: @"framework"];
|
ofType: @"framework"];
|
||||||
|
|
||||||
if(adaptorBundlePath && [adaptorBundlePath length])
|
if(adaptorBundlePath && [adaptorBundlePath length])
|
||||||
|
@ -251,7 +251,7 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
|
||||||
NSStringFromSelector(_cmd),
|
NSStringFromSelector(_cmd),
|
||||||
NSStringFromClass([self class]),
|
NSStringFromClass([self class]),
|
||||||
self,
|
self,
|
||||||
adaptorName];
|
name];
|
||||||
|
|
||||||
/* Get the adaptor bundle "infoDictionary", and pricipal class, ie. the
|
/* Get the adaptor bundle "infoDictionary", and pricipal class, ie. the
|
||||||
adaptor class. Other info about the adaptor should be put in the
|
adaptor class. Other info about the adaptor should be put in the
|
||||||
|
@ -281,7 +281,7 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
|
||||||
NSStringFromSelector(_cmd),
|
NSStringFromSelector(_cmd),
|
||||||
NSStringFromClass([self class]),
|
NSStringFromClass([self class]),
|
||||||
self,
|
self,
|
||||||
adaptorName];
|
name];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([adaptorClass isSubclassOfClass: [self class]] == NO)
|
if ([adaptorClass isSubclassOfClass: [self class]] == NO)
|
||||||
|
@ -294,7 +294,7 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
|
||||||
NSStringFromClass([adaptorClass class])];
|
NSStringFromClass([adaptorClass class])];
|
||||||
}
|
}
|
||||||
|
|
||||||
return AUTORELEASE([[adaptorClass alloc] initWithName: adaptorName]);
|
return AUTORELEASE([[adaptorClass alloc] initWithName: name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)setExpressionClassName: (NSString *)sqlExpressionClassName
|
+ (void)setExpressionClassName: (NSString *)sqlExpressionClassName
|
||||||
|
|
|
@ -117,10 +117,10 @@ inRowDescribedByQualifier: (EOQualifier *)qualifier
|
||||||
/* Fetching rows */
|
/* Fetching rows */
|
||||||
- (void)selectAttributes: (NSArray *)attributes
|
- (void)selectAttributes: (NSArray *)attributes
|
||||||
fetchSpecification: (EOFetchSpecification *)fetchSpecification
|
fetchSpecification: (EOFetchSpecification *)fetchSpecification
|
||||||
lock: (BOOL)lockFlag
|
lock: (BOOL)flag
|
||||||
entity: (EOEntity *)entity;
|
entity: (EOEntity *)entity;
|
||||||
|
|
||||||
- (void)lockRowComparingAttributes: (NSArray *)atts
|
- (void)lockRowComparingAttributes: (NSArray *)attrs
|
||||||
entity: (EOEntity *)entity
|
entity: (EOEntity *)entity
|
||||||
qualifier: (EOQualifier *)qualifier
|
qualifier: (EOQualifier *)qualifier
|
||||||
snapshot: (NSDictionary *)snapshot;
|
snapshot: (NSDictionary *)snapshot;
|
||||||
|
@ -150,7 +150,7 @@ inRowDescribedByQualifier: (EOQualifier *)qualifier
|
||||||
- (void)addStoredProceduresNamed: (NSArray *)storedProcedureNames
|
- (void)addStoredProceduresNamed: (NSArray *)storedProcedureNames
|
||||||
toModel: (EOModel *)model;
|
toModel: (EOModel *)model;
|
||||||
|
|
||||||
- (void)setDebugEnabled: (BOOL)yn;
|
- (void)setDebugEnabled: (BOOL)flag;
|
||||||
- (BOOL)isDebugEnabled;
|
- (BOOL)isDebugEnabled;
|
||||||
|
|
||||||
- (id)delegate;
|
- (id)delegate;
|
||||||
|
|
|
@ -118,13 +118,13 @@ NSString *EOAdaptorOptimisticLockingFailure = @"EOAdaptorOptimisticLockingFailur
|
||||||
[self subclassResponsibility: _cmd];
|
[self subclassResponsibility: _cmd];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateValues: (NSDictionary *)row
|
- (void)updateValues: (NSDictionary *)values
|
||||||
inRowDescribedByQualifier: (EOQualifier *)qualifier
|
inRowDescribedByQualifier: (EOQualifier *)qualifier
|
||||||
entity: (EOEntity *)entity
|
entity: (EOEntity *)entity
|
||||||
{
|
{
|
||||||
int rows;
|
int rows;
|
||||||
|
|
||||||
rows = [self updateValues: row
|
rows = [self updateValues: values
|
||||||
inRowsDescribedByQualifier: qualifier
|
inRowsDescribedByQualifier: qualifier
|
||||||
entity: entity];
|
entity: entity];
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ typedef enum {
|
||||||
- (BOOL)canNestTransactions; // override
|
- (BOOL)canNestTransactions; // override
|
||||||
- (unsigned)transactionNestingLevel;
|
- (unsigned)transactionNestingLevel;
|
||||||
|
|
||||||
+ (void)setDebugEnabledDefault: (BOOL)yn;
|
+ (void)setDebugEnabledDefault: (BOOL)flag;
|
||||||
+ (BOOL)debugEnabledDefault;
|
+ (BOOL)debugEnabledDefault;
|
||||||
- (void)setDebugEnabled: (BOOL)debugEnabled;
|
- (void)setDebugEnabled: (BOOL)debugEnabled;
|
||||||
- (BOOL)isDebugEnabled;
|
- (BOOL)isDebugEnabled;
|
||||||
|
|
|
@ -114,7 +114,7 @@ GDL2ACCESS_EXPORT NSTimeInterval EODistantPastTimeInterval;
|
||||||
|
|
||||||
- (void)forgetSnapshotForGlobalID: (EOGlobalID *)gid;
|
- (void)forgetSnapshotForGlobalID: (EOGlobalID *)gid;
|
||||||
|
|
||||||
- (void)forgetSnapshotsForGlobalIDs: (NSArray *)array;
|
- (void)forgetSnapshotsForGlobalIDs: (NSArray *)gids;
|
||||||
|
|
||||||
- (void)forgetAllSnapshots;
|
- (void)forgetAllSnapshots;
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ static NSMutableArray *databaseInstances;
|
||||||
[_models removeObject: model];
|
[_models removeObject: model];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)addModelIfCompatible: (EOModel *)model;
|
- (BOOL)addModelIfCompatible: (EOModel *)model
|
||||||
{
|
{
|
||||||
BOOL modelOk = NO;
|
BOOL modelOk = NO;
|
||||||
|
|
||||||
|
@ -543,17 +543,17 @@ static NSMutableArray *databaseInstances;
|
||||||
EOFLOGObjectFnStop();
|
EOFLOGObjectFnStop();
|
||||||
};
|
};
|
||||||
|
|
||||||
- (void)forgetSnapshotsForGlobalIDs: (NSArray*)ids
|
- (void)forgetSnapshotsForGlobalIDs: (NSArray*)gids
|
||||||
{
|
{
|
||||||
NSEnumerator *gidEnum = nil;
|
NSEnumerator *gidEnum = nil;
|
||||||
id gid = nil;
|
id gid = nil;
|
||||||
|
|
||||||
EOFLOGObjectFnStart();
|
EOFLOGObjectFnStart();
|
||||||
|
|
||||||
NSAssert(ids, @"No Global IDs");
|
NSAssert(gids, @"No Global IDs");
|
||||||
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"ids=%@", ids);
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"gids=%@", gids);
|
||||||
|
|
||||||
gidEnum = [ids objectEnumerator];
|
gidEnum = [gids objectEnumerator];
|
||||||
|
|
||||||
while ((gid = [gidEnum nextObject]))
|
while ((gid = [gidEnum nextObject]))
|
||||||
{
|
{
|
||||||
|
@ -564,7 +564,7 @@ static NSMutableArray *databaseInstances;
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
postNotificationName: EOObjectsChangedInStoreNotification
|
postNotificationName: EOObjectsChangedInStoreNotification
|
||||||
object: self
|
object: self
|
||||||
userInfo: [NSDictionary dictionaryWithObject: ids
|
userInfo: [NSDictionary dictionaryWithObject: gids
|
||||||
forKey: EOInvalidatedKey]];
|
forKey: EOInvalidatedKey]];
|
||||||
|
|
||||||
EOFLOGObjectFnStop();
|
EOFLOGObjectFnStop();
|
||||||
|
|
|
@ -223,7 +223,7 @@ RCS_ID("$Id$")
|
||||||
ASSIGN(_currentEditingContext, context);
|
ASSIGN(_currentEditingContext, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)selectObjectsWithFetchSpecification: (EOFetchSpecification *)fetch
|
- (void)selectObjectsWithFetchSpecification: (EOFetchSpecification *)fetchSpecification
|
||||||
editingContext: (EOEditingContext *)context
|
editingContext: (EOEditingContext *)context
|
||||||
{
|
{
|
||||||
//should be OK
|
//should be OK
|
||||||
|
@ -235,7 +235,7 @@ RCS_ID("$Id$")
|
||||||
|
|
||||||
EOFLOGObjectFnStart();
|
EOFLOGObjectFnStart();
|
||||||
|
|
||||||
entityName = [fetch entityName];
|
entityName = [fetchSpecification entityName];
|
||||||
database = [_databaseContext database];
|
database = [_databaseContext database];
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"gsdb", @"database=%@", database);
|
EOFLOGObjectLevelArgs(@"gsdb", @"database=%@", database);
|
||||||
|
@ -244,7 +244,7 @@ RCS_ID("$Id$")
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"gsdb", @"entity name=%@", [entity name]);
|
EOFLOGObjectLevelArgs(@"gsdb", @"entity name=%@", [entity name]);
|
||||||
|
|
||||||
qualifier=[fetch qualifier];
|
qualifier=[fetchSpecification qualifier];
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"gsdb", @"qualifier=%@", qualifier);
|
EOFLOGObjectLevelArgs(@"gsdb", @"qualifier=%@", qualifier);
|
||||||
|
|
||||||
|
@ -259,18 +259,18 @@ RCS_ID("$Id$")
|
||||||
{
|
{
|
||||||
EOFetchSpecification *newFetch = nil;
|
EOFetchSpecification *newFetch = nil;
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"gsdb", @"fetch=%@", fetch);
|
EOFLOGObjectLevelArgs(@"gsdb", @"fetchSpecification=%@", fetchSpecification);
|
||||||
//howto avoid copy of uncopiable qualifiers (i.e. those who contains uncopiable key or value)
|
//howto avoid copy of uncopiable qualifiers (i.e. those who contains uncopiable key or value)
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"gsdb", @"fetch=%@", fetch);
|
EOFLOGObjectLevelArgs(@"gsdb", @"fetchSpecification=%@", fetchSpecification);
|
||||||
|
|
||||||
newFetch = [[fetch copy] autorelease];
|
newFetch = [[fetchSpecification copy] autorelease];
|
||||||
EOFLOGObjectLevelArgs(@"gsdb", @"newFetch=%@", newFetch);
|
EOFLOGObjectLevelArgs(@"gsdb", @"newFetch=%@", newFetch);
|
||||||
|
|
||||||
[newFetch setQualifier: schemaBasedQualifier];
|
[newFetch setQualifier: schemaBasedQualifier];
|
||||||
EOFLOGObjectLevelArgs(@"gsdb", @"newFetch=%@", newFetch);
|
EOFLOGObjectLevelArgs(@"gsdb", @"newFetch=%@", newFetch);
|
||||||
|
|
||||||
fetch = newFetch;
|
fetchSpecification = newFetch;
|
||||||
}
|
}
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"gsdb", @"%@ -- %@ 0x%x: isFetchInProgress=%s",
|
EOFLOGObjectLevelArgs(@"gsdb", @"%@ -- %@ 0x%x: isFetchInProgress=%s",
|
||||||
|
@ -279,7 +279,7 @@ RCS_ID("$Id$")
|
||||||
self,
|
self,
|
||||||
([self isFetchInProgress] ? "YES" : "NO"));
|
([self isFetchInProgress] ? "YES" : "NO"));
|
||||||
|
|
||||||
[self _selectWithFetchSpecification:fetch
|
[self _selectWithFetchSpecification:fetchSpecification
|
||||||
editingContext:context];
|
editingContext:context];
|
||||||
|
|
||||||
EOFLOGObjectFnStop();
|
EOFLOGObjectFnStop();
|
||||||
|
|
|
@ -157,7 +157,7 @@ struct _EOTransactionScope;
|
||||||
|
|
||||||
- (id)faultForRawRow: (NSDictionary *)row
|
- (id)faultForRawRow: (NSDictionary *)row
|
||||||
entityNamed: (NSString *)entityName
|
entityNamed: (NSString *)entityName
|
||||||
editingContext: (EOEditingContext *)editingContext;
|
editingContext: (EOEditingContext *)context;
|
||||||
|
|
||||||
- (id)entityForGlobalID: (EOGlobalID *)globalID;
|
- (id)entityForGlobalID: (EOGlobalID *)globalID;
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ struct _EOTransactionScope;
|
||||||
editingContext: (EOEditingContext *)context;
|
editingContext: (EOEditingContext *)context;
|
||||||
|
|
||||||
- (NSArray *)arrayFaultWithSourceGlobalID: (EOGlobalID *)globalID
|
- (NSArray *)arrayFaultWithSourceGlobalID: (EOGlobalID *)globalID
|
||||||
relationshipName: (NSString *)name
|
relationshipName: (NSString *)relationshipName
|
||||||
editingContext: (EOEditingContext *)context;
|
editingContext: (EOEditingContext *)context;
|
||||||
|
|
||||||
- (void)initializeObject: (id)object
|
- (void)initializeObject: (id)object
|
||||||
|
@ -192,7 +192,7 @@ struct _EOTransactionScope;
|
||||||
- (BOOL)isObjectLockedWithGlobalID: (EOGlobalID *)gid
|
- (BOOL)isObjectLockedWithGlobalID: (EOGlobalID *)gid
|
||||||
editingContext: (EOEditingContext *)context;
|
editingContext: (EOEditingContext *)context;
|
||||||
|
|
||||||
- (void)lockObjectWithGlobalID: (EOGlobalID *)gid
|
- (void)lockObjectWithGlobalID: (EOGlobalID *)globalID
|
||||||
editingContext: (EOEditingContext *)context;
|
editingContext: (EOEditingContext *)context;
|
||||||
|
|
||||||
- (void)invalidateAllObjects;
|
- (void)invalidateAllObjects;
|
||||||
|
@ -252,8 +252,8 @@ It's invoked after prepareForSaveWithCoordinator:editingContext: and before owns
|
||||||
- (EODatabaseOperation*)databaseOperationForObject: (id)object;
|
- (EODatabaseOperation*)databaseOperationForObject: (id)object;
|
||||||
- (EODatabaseOperation*)databaseOperationForGlobalID: (EOGlobalID *)gid;
|
- (EODatabaseOperation*)databaseOperationForGlobalID: (EOGlobalID *)gid;
|
||||||
- (void)recordDatabaseOperation: (EODatabaseOperation*)databaseOpe;
|
- (void)recordDatabaseOperation: (EODatabaseOperation*)databaseOpe;
|
||||||
- (void)recordDeleteForObject: (id)param0;
|
- (void)recordDeleteForObject: (id)object;
|
||||||
- (void)recordInsertForObject: (id)param0;
|
- (void)recordInsertForObject: (id)object;
|
||||||
|
|
||||||
- (void)createAdaptorOperationsForDatabaseOperation: (EODatabaseOperation *)dbOpe
|
- (void)createAdaptorOperationsForDatabaseOperation: (EODatabaseOperation *)dbOpe
|
||||||
attributes: (NSArray *)attributes;
|
attributes: (NSArray *)attributes;
|
||||||
|
@ -266,7 +266,7 @@ It's invoked after prepareForSaveWithCoordinator:editingContext: and before owns
|
||||||
- (BOOL)isValidQualifierTypeForAttribute: (EOAttribute *)attribute;
|
- (BOOL)isValidQualifierTypeForAttribute: (EOAttribute *)attribute;
|
||||||
- (id)lockingNonQualifiableAttributes: (NSArray *)attributes;
|
- (id)lockingNonQualifiableAttributes: (NSArray *)attributes;
|
||||||
- (NSArray *)lockingAttributesForAttributes: (NSArray *)attributes
|
- (NSArray *)lockingAttributesForAttributes: (NSArray *)attributes
|
||||||
entity: (EOEntity *)enity;
|
entity: (EOEntity *)entity;
|
||||||
- (NSArray *)primaryKeyAttributesForAttributes: (NSArray *)attributes
|
- (NSArray *)primaryKeyAttributesForAttributes: (NSArray *)attributes
|
||||||
entity: (EOEntity *)entity;
|
entity: (EOEntity *)entity;
|
||||||
- (EOQualifier *)qualifierForLockingAttributes: (NSArray *)attributes
|
- (EOQualifier *)qualifierForLockingAttributes: (NSArray *)attributes
|
||||||
|
|
|
@ -1323,7 +1323,7 @@ userInfo = {
|
||||||
EOFLOGObjectFnStop();
|
EOFLOGObjectFnStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)objectsWithFetchSpecification: (EOFetchSpecification *)fetch
|
- (NSArray *)objectsWithFetchSpecification: (EOFetchSpecification *)fetchSpecification
|
||||||
editingContext: (EOEditingContext *)context
|
editingContext: (EOEditingContext *)context
|
||||||
{ // TODO
|
{ // TODO
|
||||||
EODatabaseChannel *channel = nil;
|
EODatabaseChannel *channel = nil;
|
||||||
|
@ -1346,12 +1346,12 @@ userInfo = {
|
||||||
|
|
||||||
EOFLOGObjectFnStart();
|
EOFLOGObjectFnStart();
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext", @"fetch=%@", fetch);
|
NSDebugMLLog(@"EODatabaseContext", @"fetchSpecification=%@", fetchSpecification);
|
||||||
|
|
||||||
if (_delegateRespondsTo.shouldFetchObjects == YES)
|
if (_delegateRespondsTo.shouldFetchObjects == YES)
|
||||||
{
|
{
|
||||||
array = (id)[_delegate databaseContext: self
|
array = (id)[_delegate databaseContext: self
|
||||||
shouldFetchObjectsWithFetchSpecification: fetch
|
shouldFetchObjectsWithFetchSpecification: fetchSpecification
|
||||||
editingContext: context];
|
editingContext: context];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1360,28 +1360,28 @@ userInfo = {
|
||||||
IMP enumNO=NULL; // nextObject
|
IMP enumNO=NULL; // nextObject
|
||||||
array = [NSMutableArray arrayWithCapacity: 8];
|
array = [NSMutableArray arrayWithCapacity: 8];
|
||||||
|
|
||||||
entityName = [fetch entityName];//OK
|
entityName = [fetchSpecification entityName];//OK
|
||||||
entity = [_database entityNamed: entityName];//OK
|
entity = [_database entityNamed: entityName];//OK
|
||||||
NSAssert1(entity,@"No entity named %@",
|
NSAssert1(entity,@"No entity named %@",
|
||||||
entityName);
|
entityName);
|
||||||
|
|
||||||
/* moved in EODatabaseChannel _selectWithFetchSpecification:(EOFetchSpecification *)fetch
|
/* moved in EODatabaseChannel _selectWithFetchSpecification:(EOFetchSpecification *)fetchSpecification
|
||||||
editingContext:(EOEditingContext *)context
|
editingContext:(EOEditingContext *)context
|
||||||
|
|
||||||
limit = [fetch fetchLimit];
|
limit = [fetchSpecification fetchLimit];
|
||||||
usesDistinct = [fetch usesDistinct];
|
usesDistinct = [fetchSpecification usesDistinct];
|
||||||
|
|
||||||
|
|
||||||
subEntities = [entity subEntities];
|
subEntities = [entity subEntities];
|
||||||
|
|
||||||
if ([subEntities count] && [fetch isDeep] == YES)
|
if ([subEntities count] && [fetchSpecification isDeep] == YES)
|
||||||
{
|
{
|
||||||
subEntitiesEnum = [subEntities objectEnumerator];
|
subEntitiesEnum = [subEntities objectEnumerator];
|
||||||
while ((subEntity = [subEntitiesEnum nextObject]))
|
while ((subEntity = [subEntitiesEnum nextObject]))
|
||||||
{
|
{
|
||||||
EOFetchSpecification *fetchSubEntity;
|
EOFetchSpecification *fetchSubEntity;
|
||||||
|
|
||||||
fetchSubEntity = AUTORELEASE([fetch copy]);
|
fetchSubEntity = AUTORELEASE([fetchSpecification copy]);
|
||||||
[fetchSubEntity setEntityName:[entity name]];
|
[fetchSubEntity setEntityName:[entity name]];
|
||||||
|
|
||||||
[array addObjectsFromArray:[context objectsWithFetchSpecification:
|
[array addObjectsFromArray:[context objectsWithFetchSpecification:
|
||||||
|
@ -1389,7 +1389,7 @@ userInfo = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
rawRowKeyPaths = [fetch rawRowKeyPaths];//OK
|
rawRowKeyPaths = [fetchSpecification rawRowKeyPaths];//OK
|
||||||
if (rawRowKeyPaths)
|
if (rawRowKeyPaths)
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
|
@ -1437,15 +1437,15 @@ userInfo = {
|
||||||
NSAutoreleasePool *arp = nil;//To avoid too much memory use when fetching a lot of objects
|
NSAutoreleasePool *arp = nil;//To avoid too much memory use when fetching a lot of objects
|
||||||
int limit = 0;
|
int limit = 0;
|
||||||
|
|
||||||
[channel selectObjectsWithFetchSpecification: fetch
|
[channel selectObjectsWithFetchSpecification: fetchSpecification
|
||||||
editingContext: context];//OK
|
editingContext: context];//OK
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext",
|
NSDebugMLLog(@"EODatabaseContext",
|
||||||
@"[channel isFetchInProgress]=%s",
|
@"[channel isFetchInProgress]=%s",
|
||||||
([channel isFetchInProgress] ? "YES" : "NO"));
|
([channel isFetchInProgress] ? "YES" : "NO"));
|
||||||
|
|
||||||
limit = [fetch fetchLimit];//OK
|
limit = [fetchSpecification fetchLimit];//OK
|
||||||
promptsAfterFetchLimit = [fetch promptsAfterFetchLimit];
|
promptsAfterFetchLimit = [fetchSpecification promptsAfterFetchLimit];
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext", @"Will Fetch");
|
NSDebugMLLog(@"EODatabaseContext", @"Will Fetch");
|
||||||
|
|
||||||
|
@ -1583,7 +1583,7 @@ userInfo = {
|
||||||
EOGlobalID *gid;
|
EOGlobalID *gid;
|
||||||
BOOL isFault;
|
BOOL isFault;
|
||||||
|
|
||||||
qualifier = [fetch qualifier];
|
qualifier = [fetchSpecification qualifier];
|
||||||
|
|
||||||
cache = (id)[_database resultCacheForEntityNamed: entityName];
|
cache = (id)[_database resultCacheForEntityNamed: entityName];
|
||||||
if (cache == nil)
|
if (cache == nil)
|
||||||
|
@ -1739,9 +1739,9 @@ userInfo = {
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext", @"array before sort: %@", array);
|
NSDebugMLLog(@"EODatabaseContext", @"array before sort: %@", array);
|
||||||
|
|
||||||
if ([fetch sortOrderings])
|
if ([fetchSpecification sortOrderings])
|
||||||
array = (id)[array sortedArrayUsingKeyOrderArray:
|
array = (id)[array sortedArrayUsingKeyOrderArray:
|
||||||
[fetch sortOrderings]];
|
[fetchSpecification sortOrderings]];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1780,7 +1780,7 @@ userInfo = {
|
||||||
NSAutoreleasePool *arp = nil;//To avoid too much memory use when fetching a lot of objects
|
NSAutoreleasePool *arp = nil;//To avoid too much memory use when fetching a lot of objects
|
||||||
int limit = 0;
|
int limit = 0;
|
||||||
|
|
||||||
[channel selectObjectsWithFetchSpecification: fetch
|
[channel selectObjectsWithFetchSpecification: fetchSpecification
|
||||||
editingContext: context];//OK
|
editingContext: context];//OK
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext",
|
NSDebugMLLog(@"EODatabaseContext",
|
||||||
|
@ -1788,8 +1788,8 @@ userInfo = {
|
||||||
([channel isFetchInProgress]
|
([channel isFetchInProgress]
|
||||||
? "YES" : "NO"));
|
? "YES" : "NO"));
|
||||||
|
|
||||||
limit = [fetch fetchLimit];//OK
|
limit = [fetchSpecification fetchLimit];//OK
|
||||||
promptsAfterFetchLimit = [fetch promptsAfterFetchLimit];
|
promptsAfterFetchLimit = [fetchSpecification promptsAfterFetchLimit];
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext", @"Will Fetch");
|
NSDebugMLLog(@"EODatabaseContext", @"Will Fetch");
|
||||||
|
|
||||||
|
@ -1925,10 +1925,10 @@ userInfo = {
|
||||||
NSDebugMLLog(@"EODatabaseContext",
|
NSDebugMLLog(@"EODatabaseContext",
|
||||||
@"array before prefetchingRelationshipKeyPaths: %@", array);
|
@"array before prefetchingRelationshipKeyPaths: %@", array);
|
||||||
|
|
||||||
if ([fetch prefetchingRelationshipKeyPaths]) //OK
|
if ([fetchSpecification prefetchingRelationshipKeyPaths]) //OK
|
||||||
qualArray = [NSMutableArray arrayWithCapacity: 5];
|
qualArray = [NSMutableArray arrayWithCapacity: 5];
|
||||||
|
|
||||||
relationshipKeyPathEnum = [[fetch prefetchingRelationshipKeyPaths]
|
relationshipKeyPathEnum = [[fetchSpecification prefetchingRelationshipKeyPaths]
|
||||||
objectEnumerator];
|
objectEnumerator];
|
||||||
enumNO=NULL;
|
enumNO=NULL;
|
||||||
while ((relationshipKeyPath = GDL2_NextObjectWithImpPtr(relationshipKeyPathEnum,&enumNO)))
|
while ((relationshipKeyPath = GDL2_NextObjectWithImpPtr(relationshipKeyPathEnum,&enumNO)))
|
||||||
|
@ -1958,7 +1958,7 @@ userInfo = {
|
||||||
if (_delegateRespondsTo.didFetchObjects == YES)
|
if (_delegateRespondsTo.didFetchObjects == YES)
|
||||||
[_delegate databaseContext: self
|
[_delegate databaseContext: self
|
||||||
didFetchObjects: array
|
didFetchObjects: array
|
||||||
fetchSpecification: fetch
|
fetchSpecification: fetchSpecification
|
||||||
editingContext: context];
|
editingContext: context];
|
||||||
|
|
||||||
NSDebugMLLog(@"EODatabaseContext",@"step 1 channel is busy=%d",
|
NSDebugMLLog(@"EODatabaseContext",@"step 1 channel is busy=%d",
|
||||||
|
|
|
@ -67,12 +67,12 @@
|
||||||
- (void)setFetchSpecification: (EOFetchSpecification *)fetchSpecification;
|
- (void)setFetchSpecification: (EOFetchSpecification *)fetchSpecification;
|
||||||
- (EOFetchSpecification *)fetchSpecification;
|
- (EOFetchSpecification *)fetchSpecification;
|
||||||
|
|
||||||
- (void)setAuxiliaryQualifier: (EOQualifier *)newQualifier;
|
- (void)setAuxiliaryQualifier: (EOQualifier *)qualifier;
|
||||||
- (EOQualifier *)auxiliaryQualifier;
|
- (EOQualifier *)auxiliaryQualifier;
|
||||||
|
|
||||||
- (EOFetchSpecification *)fetchSpecificationForFetch;
|
- (EOFetchSpecification *)fetchSpecificationForFetch;
|
||||||
|
|
||||||
- (void)setFetchEnabled: (BOOL)yn;
|
- (void)setFetchEnabled: (BOOL)flag;
|
||||||
- (BOOL)isFetchEnabled;
|
- (BOOL)isFetchEnabled;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -164,7 +164,7 @@ The newRow dictionary is created when creating the database operation (in EOData
|
||||||
- (EOEntity *)entity;
|
- (EOEntity *)entity;
|
||||||
|
|
||||||
- (EODatabaseOperator)databaseOperator;
|
- (EODatabaseOperator)databaseOperator;
|
||||||
- (void)setDatabaseOperator: (EODatabaseOperator)dbOp;
|
- (void)setDatabaseOperator: (EODatabaseOperator)dbOpe;
|
||||||
|
|
||||||
- (NSDictionary *)rowDiffs;
|
- (NSDictionary *)rowDiffs;
|
||||||
- (NSDictionary *)rowDiffsForAttributes: (NSArray *)attributes;
|
- (NSDictionary *)rowDiffsForAttributes: (NSArray *)attributes;
|
||||||
|
|
|
@ -143,7 +143,7 @@
|
||||||
/* Accessing attributes */
|
/* Accessing attributes */
|
||||||
- (NSArray *)attributes;
|
- (NSArray *)attributes;
|
||||||
- (EOAttribute *)attributeNamed: (NSString *)attributeName;
|
- (EOAttribute *)attributeNamed: (NSString *)attributeName;
|
||||||
- (EOAttribute *)anyAttributeNamed: (NSString *)relationshipName;
|
- (EOAttribute *)anyAttributeNamed: (NSString *)attributeName;
|
||||||
|
|
||||||
/* Accessing relationships */
|
/* Accessing relationships */
|
||||||
- (NSArray *)relationships;
|
- (NSArray *)relationships;
|
||||||
|
|
|
@ -1169,12 +1169,12 @@ static void performSelectorOnArrayWithEachObjectOfClass(NSArray *arr, SEL select
|
||||||
return [[self relationshipsByName] objectForKey: relationshipName];
|
return [[self relationshipsByName] objectForKey: relationshipName];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (EORelationship *)anyRelationshipNamed: (NSString *)relationshipNamed
|
- (EORelationship *)anyRelationshipNamed: (NSString *)relationshipName
|
||||||
{
|
{
|
||||||
EORelationship *rel;
|
EORelationship *rel;
|
||||||
NSEnumerator *relEnum = nil;
|
NSEnumerator *relEnum = nil;
|
||||||
|
|
||||||
rel = [self relationshipNamed: relationshipNamed];
|
rel = [self relationshipNamed: relationshipName];
|
||||||
|
|
||||||
//VERIFY
|
//VERIFY
|
||||||
if (!rel)
|
if (!rel)
|
||||||
|
@ -1186,7 +1186,7 @@ static void performSelectorOnArrayWithEachObjectOfClass(NSArray *arr, SEL select
|
||||||
|
|
||||||
while (!rel && (tmpRel = GDL2_NextObjectWithImpPtr(relEnum,&enumNO)))
|
while (!rel && (tmpRel = GDL2_NextObjectWithImpPtr(relEnum,&enumNO)))
|
||||||
{
|
{
|
||||||
if ([[tmpRel name] isEqual: relationshipNamed])
|
if ([[tmpRel name] isEqual: relationshipName])
|
||||||
rel = tmpRel;
|
rel = tmpRel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1535,25 +1535,25 @@ static void performSelectorOnArrayWithEachObjectOfClass(NSArray *arr, SEL select
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isValidAttributeUsedForLocking: (EOAttribute *)anAttribute
|
- (BOOL)isValidAttributeUsedForLocking: (EOAttribute *)attribute
|
||||||
{
|
{
|
||||||
if (!([anAttribute isKindOfClass: GDL2_EOAttributeClass]
|
if (!([attribute isKindOfClass: GDL2_EOAttributeClass]
|
||||||
&& [[self attributesByName] objectForKey: [anAttribute name]]))
|
&& [[self attributesByName] objectForKey: [attribute name]]))
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
if ([anAttribute isDerived])
|
if ([attribute isDerived])
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isValidPrimaryKeyAttribute: (EOAttribute *)anAttribute
|
- (BOOL)isValidPrimaryKeyAttribute: (EOAttribute *)attribute
|
||||||
{
|
{
|
||||||
if (!([anAttribute isKindOfClass: GDL2_EOAttributeClass]
|
if (!([attribute isKindOfClass: GDL2_EOAttributeClass]
|
||||||
&& [[self attributesByName] objectForKey: [anAttribute name]]))
|
&& [[self attributesByName] objectForKey: [attribute name]]))
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
if ([anAttribute isDerived])
|
if ([attribute isDerived])
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -1592,15 +1592,15 @@ static void performSelectorOnArrayWithEachObjectOfClass(NSArray *arr, SEL select
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isValidClassProperty: (id)aProperty
|
- (BOOL)isValidClassProperty: (id)property
|
||||||
{
|
{
|
||||||
id thePropertyName;
|
id thePropertyName;
|
||||||
|
|
||||||
if (!([aProperty isKindOfClass: GDL2_EOAttributeClass]
|
if (!([property isKindOfClass: GDL2_EOAttributeClass]
|
||||||
|| [aProperty isKindOfClass: [EORelationship class]]))
|
|| [property isKindOfClass: [EORelationship class]]))
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
thePropertyName = [(EOAttribute *)aProperty name];
|
thePropertyName = [(EOAttribute *)property name];
|
||||||
|
|
||||||
if ([[self attributesByName] objectForKey: thePropertyName]
|
if ([[self attributesByName] objectForKey: thePropertyName]
|
||||||
|| [[self relationshipsByName] objectForKey: thePropertyName])
|
|| [[self relationshipsByName] objectForKey: thePropertyName])
|
||||||
|
|
|
@ -140,12 +140,12 @@
|
||||||
- (void)_classDescriptionNeeded: (NSNotification *)notification;
|
- (void)_classDescriptionNeeded: (NSNotification *)notification;
|
||||||
- (id)_instantiatedEntities;
|
- (id)_instantiatedEntities;
|
||||||
- (void)_setPath: (NSString *)path;
|
- (void)_setPath: (NSString *)path;
|
||||||
- (EOEntity *)_entityForClass: (Class)param0;
|
- (EOEntity *)_entityForClass: (Class)aClass;
|
||||||
- (id)_childrenForEntityNamed: (id)param0;
|
- (id)_childrenForEntityNamed: (id)param0;
|
||||||
- (void)_registerChild: (id)param0
|
- (void)_registerChild: (id)param0
|
||||||
forParent: (id)param1;
|
forParent: (id)param1;
|
||||||
- (void)_setInheritanceLinks: (id)param0;
|
- (void)_setInheritanceLinks: (id)param0;
|
||||||
- (void)_removeEntity: (id)param0;
|
- (void)_removeEntity: (EOEntity *)entity;
|
||||||
- (EOEntity *)_addEntityWithPropertyList: (NSDictionary *)propertyList;
|
- (EOEntity *)_addEntityWithPropertyList: (NSDictionary *)propertyList;
|
||||||
- (void)_addFakeEntityWithPropertyList: (NSDictionary *)propertyList;
|
- (void)_addFakeEntityWithPropertyList: (NSDictionary *)propertyList;
|
||||||
- (id)_addEntity: (EOEntity *)entity;
|
- (id)_addEntity: (EOEntity *)entity;
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
- (void)setAdaptorName: (NSString *)adaptorName;
|
- (void)setAdaptorName: (NSString *)adaptorName;
|
||||||
|
|
||||||
- (void)setConnectionDictionary: (NSDictionary *)connectionDictionary;
|
- (void)setConnectionDictionary: (NSDictionary *)connectionDictionary;
|
||||||
- (void)setUserInfo: (NSDictionary *)dictionary;
|
- (void)setUserInfo: (NSDictionary *)userInfo;
|
||||||
|
|
||||||
- (void)addEntity: (EOEntity *)entity;
|
- (void)addEntity: (EOEntity *)entity;
|
||||||
- (void)removeEntity: (EOEntity *)entity;
|
- (void)removeEntity: (EOEntity *)entity;
|
||||||
|
|
|
@ -1011,6 +1011,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
|
||||||
|
|
||||||
- (void)awakeWithPropertyList: (NSDictionary *)propertyList
|
- (void)awakeWithPropertyList: (NSDictionary *)propertyList
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)encodeIntoPropertyList: (NSMutableDictionary *)propertyList
|
- (void)encodeIntoPropertyList: (NSMutableDictionary *)propertyList
|
||||||
|
@ -1246,15 +1247,17 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
|
||||||
forParent: (id)param1
|
forParent: (id)param1
|
||||||
{
|
{
|
||||||
// TODO [self notImplemented:_cmd];
|
// TODO [self notImplemented:_cmd];
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _setInheritanceLinks: (id)param0
|
- (void) _setInheritanceLinks: (id)param0
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
[self notImplemented: _cmd];
|
[self notImplemented: _cmd];
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _removeEntity: (id)entity
|
- (void) _removeEntity: (EOEntity *)entity
|
||||||
{
|
{
|
||||||
//should be ok
|
//should be ok
|
||||||
NSString *entityName = nil;
|
NSString *entityName = nil;
|
||||||
|
@ -1262,13 +1265,13 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
|
||||||
|
|
||||||
if ([entity isKindOfClass: [EOEntity class]])
|
if ([entity isKindOfClass: [EOEntity class]])
|
||||||
{
|
{
|
||||||
entityName = [(EOEntity*)entity name];
|
entityName = [entity name];
|
||||||
entityClassName = [entity className];
|
entityClassName = [entity className];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
entityName = [entity objectForKey: @"name"];
|
entityName = [(NSDictionary *)entity objectForKey: @"name"];
|
||||||
entityClassName = [entity objectForKey: @"className"];
|
entityClassName = [(NSDictionary *)entity objectForKey: @"className"];
|
||||||
}
|
}
|
||||||
|
|
||||||
[_entitiesByName removeObjectForKey: entityName];
|
[_entitiesByName removeObjectForKey: entityName];
|
||||||
|
@ -1495,7 +1498,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) removeEntityAndReferences: (EOEntity *)entity;
|
- (void) removeEntityAndReferences: (EOEntity *)entity
|
||||||
{
|
{
|
||||||
[self removeEntity: entity];
|
[self removeEntity: entity];
|
||||||
// TODO;
|
// TODO;
|
||||||
|
|
|
@ -396,7 +396,7 @@ of the mainBundle, and all bundles and frameworks loaded into the app.
|
||||||
return newFetchSpecification;
|
return newFetchSpecification;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (EOStoredProcedure *)storedProcedureNamed: (NSString *)aName
|
- (EOStoredProcedure *)storedProcedureNamed: (NSString *)name
|
||||||
{
|
{
|
||||||
EOStoredProcedure *newStoredProcedure = nil;
|
EOStoredProcedure *newStoredProcedure = nil;
|
||||||
NSEnumerator *modelEnum;
|
NSEnumerator *modelEnum;
|
||||||
|
@ -407,7 +407,7 @@ of the mainBundle, and all bundles and frameworks loaded into the app.
|
||||||
modelEnum = [_modelsByName objectEnumerator];
|
modelEnum = [_modelsByName objectEnumerator];
|
||||||
while ((model = [modelEnum nextObject]))
|
while ((model = [modelEnum nextObject]))
|
||||||
{
|
{
|
||||||
if ((newStoredProcedure = [model storedProcedureNamed: aName]))
|
if ((newStoredProcedure = [model storedProcedureNamed: name]))
|
||||||
{
|
{
|
||||||
EOFLOGObjectFnStopOrCond2(@"ModelingClasses", @"EOModelGroup");
|
EOFLOGObjectFnStopOrCond2(@"ModelingClasses", @"EOModelGroup");
|
||||||
|
|
||||||
|
@ -421,3 +421,53 @@ of the mainBundle, and all bundles and frameworks loaded into the app.
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@implementation EOObjectStoreCoordinator (EOModelGroup)
|
||||||
|
|
||||||
|
- (id)modelGroup
|
||||||
|
{
|
||||||
|
//Seems OK
|
||||||
|
EOModelGroup *modelGroup;
|
||||||
|
NSDictionary *userInfo;
|
||||||
|
|
||||||
|
EOFLOGObjectFnStart();
|
||||||
|
|
||||||
|
userInfo = [self userInfo];
|
||||||
|
modelGroup = [userInfo objectForKey: @"EOModelGroup"];
|
||||||
|
|
||||||
|
if (!modelGroup)
|
||||||
|
{
|
||||||
|
modelGroup = [EOModelGroup defaultGroup];
|
||||||
|
[self setModelGroup: modelGroup];
|
||||||
|
}
|
||||||
|
|
||||||
|
EOFLOGObjectFnStop();
|
||||||
|
|
||||||
|
return modelGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setModelGroup: (EOModelGroup *)modelGroup
|
||||||
|
{
|
||||||
|
NSMutableDictionary *userInfo;
|
||||||
|
|
||||||
|
EOFLOGObjectFnStart();
|
||||||
|
|
||||||
|
userInfo = (NSMutableDictionary *)[self userInfo];
|
||||||
|
|
||||||
|
if (userInfo)
|
||||||
|
[userInfo setObject: modelGroup
|
||||||
|
forKey: @"EOModelGroup"];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userInfo = (id)[NSMutableDictionary dictionary];
|
||||||
|
|
||||||
|
[userInfo setObject: modelGroup
|
||||||
|
forKey: @"EOModelGroup"];
|
||||||
|
[self setUserInfo: userInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
EOFLOGObjectFnStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
|
@ -160,10 +160,10 @@ typedef enum {
|
||||||
- (void)setName: (NSString *)name;
|
- (void)setName: (NSString *)name;
|
||||||
- (void)setDefinition: (NSString *)definition;
|
- (void)setDefinition: (NSString *)definition;
|
||||||
- (void)setEntity: (EOEntity *)entity;
|
- (void)setEntity: (EOEntity *)entity;
|
||||||
- (void)setToMany: (BOOL)yn;
|
- (void)setToMany: (BOOL)flag;
|
||||||
- (void)setPropagatesPrimaryKey: (BOOL)yn;
|
- (void)setPropagatesPrimaryKey: (BOOL)flag;
|
||||||
- (void)setIsBidirectional: (BOOL)yn;
|
- (void)setIsBidirectional: (BOOL)flag;
|
||||||
- (void)setOwnsDestination: (BOOL)yn;
|
- (void)setOwnsDestination: (BOOL)flag;
|
||||||
- (void)addJoin: (EOJoin *)join;
|
- (void)addJoin: (EOJoin *)join;
|
||||||
- (void)removeJoin: (EOJoin *)join;
|
- (void)removeJoin: (EOJoin *)join;
|
||||||
- (void)setJoinSemantic: (EOJoinSemantic)joinSemantic;
|
- (void)setJoinSemantic: (EOJoinSemantic)joinSemantic;
|
||||||
|
|
|
@ -97,7 +97,7 @@ GDL2ACCESS_EXPORT NSString *EOBindVariableColumnKey;
|
||||||
entity: (EOEntity *)entity;
|
entity: (EOEntity *)entity;
|
||||||
|
|
||||||
+ (EOSQLExpression *)selectStatementForAttributes: (NSArray *)attributes
|
+ (EOSQLExpression *)selectStatementForAttributes: (NSArray *)attributes
|
||||||
lock: (BOOL)yn
|
lock: (BOOL)flag
|
||||||
fetchSpecification: (EOFetchSpecification *)fetchSpecification
|
fetchSpecification: (EOFetchSpecification *)fetchSpecification
|
||||||
entity: (EOEntity *)entity;
|
entity: (EOEntity *)entity;
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ GDL2ACCESS_EXPORT NSString *EOBindVariableColumnKey;
|
||||||
- (void)prepareDeleteExpressionForQualifier: (EOQualifier *)qualifier;
|
- (void)prepareDeleteExpressionForQualifier: (EOQualifier *)qualifier;
|
||||||
|
|
||||||
- (void)prepareSelectExpressionWithAttributes: (NSArray *)attributes
|
- (void)prepareSelectExpressionWithAttributes: (NSArray *)attributes
|
||||||
lock: (BOOL)yn
|
lock: (BOOL)flag
|
||||||
fetchSpecification: (EOFetchSpecification *)fetchSpecification;
|
fetchSpecification: (EOFetchSpecification *)fetchSpecification;
|
||||||
|
|
||||||
- (NSString *)assembleJoinClauseWithLeftName: (NSString *)leftName
|
- (NSString *)assembleJoinClauseWithLeftName: (NSString *)leftName
|
||||||
|
@ -192,7 +192,7 @@ GDL2ACCESS_EXPORT NSString *EOBindVariableColumnKey;
|
||||||
- (void)addOrderByAttributeOrdering: (EOSortOrdering *)sortOrdering;
|
- (void)addOrderByAttributeOrdering: (EOSortOrdering *)sortOrdering;
|
||||||
|
|
||||||
+ (BOOL)useQuotedExternalNames;
|
+ (BOOL)useQuotedExternalNames;
|
||||||
+ (void)setUseQuotedExternalNames: (BOOL)yn;
|
+ (void)setUseQuotedExternalNames: (BOOL)flag;
|
||||||
- (NSString *)externalNameQuoteCharacter;
|
- (NSString *)externalNameQuoteCharacter;
|
||||||
|
|
||||||
- (void)setUseAliases: (BOOL)useAliases;
|
- (void)setUseAliases: (BOOL)useAliases;
|
||||||
|
@ -201,7 +201,7 @@ GDL2ACCESS_EXPORT NSString *EOBindVariableColumnKey;
|
||||||
- (NSString *)sqlStringForSchemaObjectName: (NSString *)name;
|
- (NSString *)sqlStringForSchemaObjectName: (NSString *)name;
|
||||||
- (NSString *)sqlStringForAttributeNamed: (NSString *)name;
|
- (NSString *)sqlStringForAttributeNamed: (NSString *)name;
|
||||||
- (NSString *)sqlStringForSelector: (SEL)selector value: (id)value;
|
- (NSString *)sqlStringForSelector: (SEL)selector value: (id)value;
|
||||||
- (NSString *)sqlStringForValue: (id)value attributeNamed: (NSString *)string;
|
- (NSString *)sqlStringForValue: (id)value attributeNamed: (NSString *)attributeName;
|
||||||
- (NSString *)sqlStringForAttribute: (EOAttribute *)attribute;
|
- (NSString *)sqlStringForAttribute: (EOAttribute *)attribute;
|
||||||
- (NSString *)sqlStringForAttributePath: (NSArray *)path;
|
- (NSString *)sqlStringForAttributePath: (NSArray *)path;
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ GDL2ACCESS_EXPORT NSString *EOBindVariableColumnKey;
|
||||||
- (BOOL)mustUseBindVariableForAttribute: (EOAttribute *)att;
|
- (BOOL)mustUseBindVariableForAttribute: (EOAttribute *)att;
|
||||||
|
|
||||||
+ (BOOL)useBindVariables;
|
+ (BOOL)useBindVariables;
|
||||||
+ (void)setUseBindVariables: (BOOL)yn;
|
+ (void)setUseBindVariables: (BOOL)flag;
|
||||||
|
|
||||||
- (NSArray *)bindVariableDictionaries;
|
- (NSArray *)bindVariableDictionaries;
|
||||||
- (void)addBindVariableDictionary: (NSMutableDictionary *)binding;
|
- (void)addBindVariableDictionary: (NSMutableDictionary *)binding;
|
||||||
|
|
|
@ -75,7 +75,6 @@ RCS_ID("$Id$")
|
||||||
#include <EOAccess/EOSQLExpression.h>
|
#include <EOAccess/EOSQLExpression.h>
|
||||||
#include <EOAccess/EOSQLQualifier.h>
|
#include <EOAccess/EOSQLQualifier.h>
|
||||||
#include <EOAccess/EOExpressionArray.h>
|
#include <EOAccess/EOExpressionArray.h>
|
||||||
#include <EOAccess/EOSchemaGeneration.h>
|
|
||||||
|
|
||||||
#include "EOPrivate.h"
|
#include "EOPrivate.h"
|
||||||
#include "EOEntityPriv.h"
|
#include "EOEntityPriv.h"
|
||||||
|
@ -661,7 +660,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
|
||||||
*/
|
*/
|
||||||
|
|
||||||
- (void)prepareSelectExpressionWithAttributes: (NSArray *)attributes
|
- (void)prepareSelectExpressionWithAttributes: (NSArray *)attributes
|
||||||
lock: (BOOL)lockFlag
|
lock: (BOOL)flag
|
||||||
fetchSpecification: (EOFetchSpecification *)fetchSpecification
|
fetchSpecification: (EOFetchSpecification *)fetchSpecification
|
||||||
{
|
{
|
||||||
EOQualifier *fetchQualifier = nil;
|
EOQualifier *fetchQualifier = nil;
|
||||||
|
@ -751,7 +750,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"tableList=%@", tableList);
|
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"tableList=%@", tableList);
|
||||||
|
|
||||||
//Build LockClause
|
//Build LockClause
|
||||||
if (lockFlag)
|
if (flag)
|
||||||
lockClauseString = [self lockClause];
|
lockClauseString = [self lockClause];
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"lockClauseString=%@",
|
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"lockClauseString=%@",
|
||||||
lockClauseString);
|
lockClauseString);
|
||||||
|
@ -767,7 +766,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
|
||||||
|
|
||||||
//Now Build Statement
|
//Now Build Statement
|
||||||
statement = [self assembleSelectStatementWithAttributes: attributes
|
statement = [self assembleSelectStatementWithAttributes: attributes
|
||||||
lock: lockFlag
|
lock: flag
|
||||||
qualifier: fetchQualifier
|
qualifier: fetchQualifier
|
||||||
fetchOrder: sortOrderings
|
fetchOrder: sortOrderings
|
||||||
selectString: selectCommand
|
selectString: selectCommand
|
||||||
|
@ -1855,42 +1854,42 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
|
||||||
return sqlString;
|
return sqlString;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)sqlStringForAttribute: (EOAttribute *)anAttribute
|
- (NSString *)sqlStringForAttribute: (EOAttribute *)attribute
|
||||||
{
|
{
|
||||||
NSString *sqlString = nil;
|
NSString *sqlString = nil;
|
||||||
|
|
||||||
EOFLOGObjectFnStartCond(@"EOSQLExpression");
|
EOFLOGObjectFnStartCond(@"EOSQLExpression");
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"anAttribute=%@",
|
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"attribute=%@",
|
||||||
anAttribute);
|
attribute);
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sFlattened=%s",
|
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sFlattened=%s",
|
||||||
([anAttribute isFlattened] ? "YES" : "NO"));
|
([attribute isFlattened] ? "YES" : "NO"));
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"_definitionArray=%@",
|
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"_definitionArray=%@",
|
||||||
[anAttribute _definitionArray]);
|
[attribute _definitionArray]);
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"_definitionArray count=%d",
|
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"_definitionArray count=%d",
|
||||||
[[anAttribute _definitionArray]count]);
|
[[attribute _definitionArray]count]);
|
||||||
|
|
||||||
if ([anAttribute isFlattened])
|
if ([attribute isFlattened])
|
||||||
{
|
{
|
||||||
sqlString = [self sqlStringForAttributePath:
|
sqlString = [self sqlStringForAttributePath:
|
||||||
[anAttribute _definitionArray]];
|
[attribute _definitionArray]];
|
||||||
|
|
||||||
NSAssert1(sqlString, @"No sqlString for flattened attribute: %@",
|
NSAssert1(sqlString, @"No sqlString for flattened attribute: %@",
|
||||||
anAttribute);
|
attribute);
|
||||||
}
|
}
|
||||||
//mirko:
|
//mirko:
|
||||||
/*
|
/*
|
||||||
else if([anAttribute isDerived] == YES)
|
else if([attribute isDerived] == YES)
|
||||||
return [anAttribute definition];
|
return [attribute definition];
|
||||||
*/
|
*/
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (![self useAliases])//OK
|
if (![self useAliases])//OK
|
||||||
{
|
{
|
||||||
sqlString = [anAttribute columnName];
|
sqlString = [attribute columnName];
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlString=%@", sqlString);
|
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlString=%@", sqlString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1945,9 +1944,9 @@ else if([anAttribute isDerived] == YES)
|
||||||
|
|
||||||
if (attrArray)
|
if (attrArray)
|
||||||
{
|
{
|
||||||
if ([attrArray containsObject: anAttribute])
|
if ([attrArray containsObject: attribute])
|
||||||
{
|
{
|
||||||
NSString *columnName = [anAttribute columnName];
|
NSString *columnName = [attribute columnName];
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression",
|
EOFLOGObjectLevelArgs(@"EOSQLExpression",
|
||||||
@"columnName=%@", columnName);
|
@"columnName=%@", columnName);
|
||||||
|
@ -1957,8 +1956,8 @@ else if([anAttribute isDerived] == YES)
|
||||||
NSEmitTODO(); //TODO what to do when there's no column name (definition only like "((firstName || ' ') || lastName)") ?
|
NSEmitTODO(); //TODO what to do when there's no column name (definition only like "((firstName || ' ') || lastName)") ?
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression",
|
EOFLOGObjectLevelArgs(@"EOSQLExpression",
|
||||||
@"anAttribute=%@",
|
@"attribute=%@",
|
||||||
anAttribute);
|
attribute);
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression",
|
EOFLOGObjectLevelArgs(@"EOSQLExpression",
|
||||||
@"columnName=%@", columnName);
|
@"columnName=%@", columnName);
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression",
|
EOFLOGObjectLevelArgs(@"EOSQLExpression",
|
||||||
|
@ -1969,7 +1968,7 @@ else if([anAttribute isDerived] == YES)
|
||||||
}
|
}
|
||||||
|
|
||||||
NSAssert1(columnName, @"No columnName for attribute %@",
|
NSAssert1(columnName, @"No columnName for attribute %@",
|
||||||
anAttribute);
|
attribute);
|
||||||
|
|
||||||
sqlString = [NSString stringWithFormat: @"%@.%@",
|
sqlString = [NSString stringWithFormat: @"%@.%@",
|
||||||
[_aliasesByRelationshipPath
|
[_aliasesByRelationshipPath
|
||||||
|
@ -1985,7 +1984,7 @@ else if([anAttribute isDerived] == YES)
|
||||||
sqlString);
|
sqlString);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSAssert1(sqlString, @"No SQLString for attribute %@", anAttribute);
|
NSAssert1(sqlString, @"No SQLString for attribute %@", attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlString=%@", sqlString);
|
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlString=%@", sqlString);
|
||||||
|
@ -2525,805 +2524,3 @@ All relationshipPaths in _aliasesByRelationshipPath are direct paths **/
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
NSString *EOCreateTablesKey = @"EOCreateTablesKey";
|
|
||||||
NSString *EODropTablesKey = @"EODropTablesKey";
|
|
||||||
NSString *EOCreatePrimaryKeySupportKey = @"EOCreatePrimaryKeySupportKey";
|
|
||||||
NSString *EODropPrimaryKeySupportKey = @"EODropPrimaryKeySupportKey";
|
|
||||||
NSString *EOPrimaryKeyConstraintsKey = @"EOPrimaryKeyConstraintsKey";
|
|
||||||
NSString *EOForeignKeyConstraintsKey = @"EOForeignKeyConstraintsKey";
|
|
||||||
NSString *EOCreateDatabaseKey = @"EOCreateDatabaseKey";
|
|
||||||
NSString *EODropDatabaseKey = @"EODropDatabaseKey";
|
|
||||||
|
|
||||||
|
|
||||||
@implementation EOSQLExpression (EOSchemaGeneration)
|
|
||||||
|
|
||||||
+ (NSArray *)_administrativeDatabaseStatementsForSelector:(SEL) sel
|
|
||||||
forEntityGroup:(NSArray *)group
|
|
||||||
{
|
|
||||||
EOEntity *entity;
|
|
||||||
EOModel *model;
|
|
||||||
NSDictionary *connDict;
|
|
||||||
NSDictionary *admDict;
|
|
||||||
NSArray *stmts;
|
|
||||||
NSString *notifName;
|
|
||||||
NSMutableDictionary *notifDict;
|
|
||||||
|
|
||||||
entity = [group lastObject];
|
|
||||||
model = [entity model];
|
|
||||||
connDict = [model connectionDictionary];
|
|
||||||
|
|
||||||
notifDict = (id)[NSMutableDictionary dictionaryWithCapacity: 2];
|
|
||||||
[notifDict setObject: model forKey: EOModelKey];
|
|
||||||
notifName = EOAdministrativeConnectionDictionaryNeededNotification;
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName: notifName
|
|
||||||
object: notifDict];
|
|
||||||
admDict = [notifDict objectForKey: EOAdministrativeConnectionDictionaryKey];
|
|
||||||
/* TODO: ayers
|
|
||||||
if (admDict == nil && [admDict count] == 0)
|
|
||||||
{
|
|
||||||
EOAdaptor *adaptor;
|
|
||||||
EOLoginPanel *panel;
|
|
||||||
|
|
||||||
adaptor = [EOAdaptor adaptorWithModel: model];
|
|
||||||
panel = [[adaptor class] sharedLoginPanelInstance];
|
|
||||||
admDict = [panel administrativeConnectionDictionaryForAdaptor: adaptor];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
stmts = [self performSelector: sel
|
|
||||||
withObject: connDict
|
|
||||||
withObject: admDict];
|
|
||||||
|
|
||||||
return stmts;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)_dropDatabaseStatementsForEntityGroups: (NSArray *)entityGroups
|
|
||||||
{
|
|
||||||
NSMutableArray *cumStmts;
|
|
||||||
NSArray *stmts;
|
|
||||||
NSArray *group;
|
|
||||||
unsigned i,n;
|
|
||||||
SEL sel;
|
|
||||||
|
|
||||||
sel = @selector(dropDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:);
|
|
||||||
|
|
||||||
n = [entityGroups count];
|
|
||||||
cumStmts = [NSMutableArray arrayWithCapacity: n];
|
|
||||||
|
|
||||||
for (i=0; i<n; i++)
|
|
||||||
{
|
|
||||||
EOSQLExpression *expr;
|
|
||||||
unsigned j,m;
|
|
||||||
|
|
||||||
group = [entityGroups objectAtIndex: i];
|
|
||||||
stmts = [self _administrativeDatabaseStatementsForSelector: sel
|
|
||||||
forEntityGroup: group];
|
|
||||||
for (j=0, m=[stmts count]; j<m; j++)
|
|
||||||
{
|
|
||||||
NSArray *rawStmts;
|
|
||||||
NSString *stmt;
|
|
||||||
|
|
||||||
rawStmts = [cumStmts valueForKey:@"statement"];
|
|
||||||
expr = [stmts objectAtIndex: j];
|
|
||||||
stmt = [expr statement];
|
|
||||||
|
|
||||||
if ([rawStmts containsObject: stmt] == NO)
|
|
||||||
{
|
|
||||||
[cumStmts addObject: expr];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return [NSArray arrayWithArray: cumStmts];
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)_createDatabaseStatementsForEntityGroups: (NSArray *)entityGroups
|
|
||||||
{
|
|
||||||
NSMutableArray *cumStmts;
|
|
||||||
NSArray *stmts;
|
|
||||||
NSArray *group;
|
|
||||||
unsigned i,n;
|
|
||||||
SEL sel;
|
|
||||||
|
|
||||||
sel = @selector(createDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:);
|
|
||||||
|
|
||||||
n = [entityGroups count];
|
|
||||||
cumStmts = [NSMutableArray arrayWithCapacity: n];
|
|
||||||
|
|
||||||
for (i=0; i<n; i++)
|
|
||||||
{
|
|
||||||
EOSQLExpression *expr;
|
|
||||||
unsigned j,m;
|
|
||||||
|
|
||||||
group = [entityGroups objectAtIndex: i];
|
|
||||||
stmts = [self _administrativeDatabaseStatementsForSelector: sel
|
|
||||||
forEntityGroup: group];
|
|
||||||
|
|
||||||
for (j=0, m=[stmts count]; j<m; j++)
|
|
||||||
{
|
|
||||||
NSArray *rawStmts;
|
|
||||||
NSString *stmt;
|
|
||||||
|
|
||||||
rawStmts = [cumStmts valueForKey:@"statement"];
|
|
||||||
expr = [stmts objectAtIndex: j];
|
|
||||||
stmt = [expr statement];
|
|
||||||
|
|
||||||
if ([rawStmts containsObject: stmt] == NO)
|
|
||||||
{
|
|
||||||
[cumStmts addObject: expr];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return [NSArray arrayWithArray: cumStmts];
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)foreignKeyConstraintStatementsForRelationship: (EORelationship *)relationship
|
|
||||||
{
|
|
||||||
NSMutableArray *array, *sourceColumns, *destColumns;
|
|
||||||
EOSQLExpression *sqlExpression;
|
|
||||||
EOEntity *entity;
|
|
||||||
NSEnumerator *joinEnum;
|
|
||||||
EOJoin *join;
|
|
||||||
unsigned num;
|
|
||||||
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
array = [NSMutableArray arrayWithCapacity: 1];
|
|
||||||
|
|
||||||
if ([[relationship entity] model]
|
|
||||||
!= [[relationship destinationEntity] model])
|
|
||||||
{
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([relationship isToMany] == YES
|
|
||||||
|| ([relationship inverseRelationship] != nil
|
|
||||||
&& [[relationship inverseRelationship] isToMany] == NO))
|
|
||||||
{
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity = [relationship entity];
|
|
||||||
sqlExpression = [self sqlExpressionWithEntity: entity];
|
|
||||||
|
|
||||||
num = [[relationship joins] count];
|
|
||||||
|
|
||||||
sourceColumns = [NSMutableArray arrayWithCapacity: num];
|
|
||||||
destColumns = [NSMutableArray arrayWithCapacity: num];
|
|
||||||
|
|
||||||
joinEnum = [[relationship joins] objectEnumerator];
|
|
||||||
while ((join = [joinEnum nextObject]))
|
|
||||||
{
|
|
||||||
[sourceColumns addObject: [join sourceAttribute]];
|
|
||||||
[destColumns addObject: [join destinationAttribute]];
|
|
||||||
}
|
|
||||||
|
|
||||||
[sqlExpression prepareConstraintStatementForRelationship: relationship
|
|
||||||
sourceColumns: sourceColumns
|
|
||||||
destinationColumns: destColumns];
|
|
||||||
|
|
||||||
[array addObject: sqlExpression];
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)foreignKeyConstraintStatementsForEntityGroup:(NSArray *)entityGroup
|
|
||||||
{
|
|
||||||
NSMutableArray *sqlExps;
|
|
||||||
EORelationship *rel;
|
|
||||||
EOEntity *entity;
|
|
||||||
EOEntity *parentEntity;
|
|
||||||
unsigned i,j,n,m;
|
|
||||||
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
sqlExps = [NSMutableArray array];
|
|
||||||
|
|
||||||
for (i=0, n=[entityGroup count]; i<n; i++)
|
|
||||||
{
|
|
||||||
NSArray *rels;
|
|
||||||
|
|
||||||
entity = [entityGroup objectAtIndex: i];
|
|
||||||
parentEntity = [entity parentEntity];
|
|
||||||
rels = [entity relationships];
|
|
||||||
|
|
||||||
for (j=0, m=[rels count]; parentEntity == nil && j<m; j++)
|
|
||||||
{
|
|
||||||
NSArray *stmts;
|
|
||||||
|
|
||||||
rel = [rels objectAtIndex: j];
|
|
||||||
stmts =[self foreignKeyConstraintStatementsForRelationship: rel];
|
|
||||||
[sqlExps addObjectsFromArray: stmts];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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]))
|
|
||||||
{
|
|
||||||
NSArray *stmts;
|
|
||||||
|
|
||||||
stmts = [self foreignKeyConstraintStatementsForEntityGroup: group];
|
|
||||||
[array addObjectsFromArray: stmts];
|
|
||||||
}
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
// default implementation verifies that relationship joins on foreign key
|
|
||||||
// of destination and calls
|
|
||||||
// prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:
|
|
||||||
|
|
||||||
+ (NSArray *)createTableStatementsForEntityGroup: (NSArray *)entityGroup
|
|
||||||
{
|
|
||||||
EOSQLExpression *sqlExp;
|
|
||||||
NSEnumerator *entityEnum, *attrEnum;
|
|
||||||
EOAttribute *attr;
|
|
||||||
EOEntity *entity;
|
|
||||||
NSString *tableName;
|
|
||||||
NSString *stmt;
|
|
||||||
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
if ([[entityGroup objectAtIndex:0] isAbstractEntity])
|
|
||||||
return [NSArray array];
|
|
||||||
|
|
||||||
sqlExp = [self sqlExpressionWithEntity:[entityGroup objectAtIndex: 0]];
|
|
||||||
|
|
||||||
entityEnum = [entityGroup objectEnumerator];
|
|
||||||
while ((entity = [entityEnum nextObject]))
|
|
||||||
{
|
|
||||||
attrEnum = [[entity attributes] objectEnumerator];
|
|
||||||
|
|
||||||
while ((attr = [attrEnum nextObject]))
|
|
||||||
[sqlExp addCreateClauseForAttribute: attr];
|
|
||||||
}
|
|
||||||
|
|
||||||
entity = [entityGroup objectAtIndex: 0];
|
|
||||||
tableName = [entity externalName];
|
|
||||||
tableName = [sqlExp sqlStringForSchemaObjectName: tableName];
|
|
||||||
|
|
||||||
stmt = [NSString stringWithFormat: @"CREATE TABLE %@ (%@)",
|
|
||||||
tableName,
|
|
||||||
[sqlExp listString]];
|
|
||||||
[sqlExp setStatement: stmt];
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return [NSArray arrayWithObject: sqlExp];
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)dropTableStatementsForEntityGroup:(NSArray *)entityGroup
|
|
||||||
{
|
|
||||||
NSArray *newArray;
|
|
||||||
NSString *tableName;
|
|
||||||
EOEntity *entity;
|
|
||||||
NSString *stmt;
|
|
||||||
EOSQLExpression *sqlExp;
|
|
||||||
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
entity = [entityGroup objectAtIndex: 0];
|
|
||||||
|
|
||||||
if ([entity isAbstractEntity])
|
|
||||||
return [NSArray array];
|
|
||||||
|
|
||||||
sqlExp = [self sqlExpressionWithEntity: entity];
|
|
||||||
tableName = [entity externalName];
|
|
||||||
tableName = [sqlExp sqlStringForSchemaObjectName: tableName];
|
|
||||||
|
|
||||||
stmt = [NSString stringWithFormat: @"DROP TABLE %@", tableName];
|
|
||||||
[sqlExp setStatement: stmt];
|
|
||||||
newArray = [NSArray arrayWithObject: sqlExp];
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return newArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroup:(NSArray *)entityGroup
|
|
||||||
{
|
|
||||||
EOSQLExpression *sqlExp;
|
|
||||||
NSMutableString *listString;
|
|
||||||
NSEnumerator *attrEnum;
|
|
||||||
EOAttribute *attr;
|
|
||||||
EOEntity *entity;
|
|
||||||
NSString *tableName;
|
|
||||||
NSString *stmt;
|
|
||||||
BOOL first = YES;
|
|
||||||
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
entity = [entityGroup objectAtIndex: 0];
|
|
||||||
listString = [NSMutableString stringWithCapacity: 30];
|
|
||||||
|
|
||||||
attrEnum = [[entity primaryKeyAttributes] objectEnumerator];
|
|
||||||
while ((attr = [attrEnum nextObject]))
|
|
||||||
{
|
|
||||||
NSString *columnName = [attr columnName];
|
|
||||||
|
|
||||||
if (!columnName || ![columnName length])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (first == NO)
|
|
||||||
[listString appendString: @", "];
|
|
||||||
|
|
||||||
[listString appendString: columnName];
|
|
||||||
first = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (first == YES)
|
|
||||||
{
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return [NSArray array];
|
|
||||||
}
|
|
||||||
|
|
||||||
sqlExp = [self sqlExpressionWithEntity:[entityGroup objectAtIndex: 0]];
|
|
||||||
tableName = [entity externalName];
|
|
||||||
tableName = [sqlExp sqlStringForSchemaObjectName: tableName];
|
|
||||||
|
|
||||||
stmt = [NSString stringWithFormat: @"ALTER TABLE %@ ADD PRIMARY KEY (%@)",
|
|
||||||
tableName, listString];
|
|
||||||
[sqlExp setStatement: stmt];
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return [NSArray arrayWithObject: sqlExp];
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)primaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup
|
|
||||||
{
|
|
||||||
NSArray *newArray;
|
|
||||||
NSString *seqName;
|
|
||||||
EOEntity *entity;
|
|
||||||
NSString *pkRootName;
|
|
||||||
NSString *stmt;
|
|
||||||
EOSQLExpression *sqlExp;
|
|
||||||
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
entity = [entityGroup objectAtIndex: 0];
|
|
||||||
|
|
||||||
if ([entity isAbstractEntity])
|
|
||||||
return [NSArray array];
|
|
||||||
|
|
||||||
pkRootName = [entity primaryKeyRootName];
|
|
||||||
seqName = [NSString stringWithFormat: @"%@_SEQ", pkRootName];
|
|
||||||
|
|
||||||
sqlExp = [self sqlExpressionWithEntity: nil];
|
|
||||||
seqName = [sqlExp sqlStringForSchemaObjectName: seqName];
|
|
||||||
|
|
||||||
stmt = [NSString stringWithFormat: @"CREATE SEQUENCE %@", seqName];
|
|
||||||
[sqlExp setStatement: stmt];
|
|
||||||
newArray = [NSArray arrayWithObject: sqlExp];
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return newArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup
|
|
||||||
{
|
|
||||||
NSArray *newArray;
|
|
||||||
NSString *seqName;
|
|
||||||
EOEntity *entity;
|
|
||||||
NSString *pkRootName;
|
|
||||||
NSString *stmt;
|
|
||||||
EOSQLExpression *sqlExp;
|
|
||||||
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
entity = [entityGroup objectAtIndex: 0];
|
|
||||||
|
|
||||||
if ([entity isAbstractEntity])
|
|
||||||
return [NSArray array];
|
|
||||||
|
|
||||||
pkRootName = [entity primaryKeyRootName];
|
|
||||||
seqName = [NSString stringWithFormat: @"%@_SEQ", pkRootName];
|
|
||||||
|
|
||||||
sqlExp = [self sqlExpressionWithEntity: nil];
|
|
||||||
seqName = [sqlExp sqlStringForSchemaObjectName: seqName];
|
|
||||||
|
|
||||||
stmt = [NSString stringWithFormat: @"DROP SEQUENCE %@", seqName];
|
|
||||||
[sqlExp setStatement: stmt];
|
|
||||||
newArray = [NSArray arrayWithObject: sqlExp];
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return newArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)createTableStatementsForEntityGroups: (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 createTableStatementsForEntityGroup: group]];
|
|
||||||
}
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)dropTableStatementsForEntityGroups: (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 dropTableStatementsForEntityGroup: group]];
|
|
||||||
}
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroups: (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 primaryKeyConstraintStatementsForEntityGroup: group]];
|
|
||||||
}
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)primaryKeySupportStatementsForEntityGroups: (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 primaryKeySupportStatementsForEntityGroup: group]];
|
|
||||||
}
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroups: (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 dropPrimaryKeySupportStatementsForEntityGroup: group]];
|
|
||||||
}
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (void)appendExpression: (EOSQLExpression *)expression
|
|
||||||
toScript: (NSMutableString *)script
|
|
||||||
{
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
[script appendFormat:@"%@;\n", [expression statement]];
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
+ (NSString *)schemaCreationScriptForEntities: (NSArray *)entities
|
|
||||||
options: (NSDictionary *)options
|
|
||||||
{
|
|
||||||
NSMutableString *script = [NSMutableString stringWithCapacity:50];
|
|
||||||
NSEnumerator *arrayEnum;
|
|
||||||
EOSQLExpression *sqlExp;
|
|
||||||
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
arrayEnum = [[self schemaCreationStatementsForEntities: entities
|
|
||||||
options: options] objectEnumerator];
|
|
||||||
|
|
||||||
while ((sqlExp = [arrayEnum nextObject]))
|
|
||||||
[self appendExpression: sqlExp toScript: script];
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return script;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct _schema
|
|
||||||
{
|
|
||||||
NSString *key;
|
|
||||||
NSString *value;
|
|
||||||
SEL selector;
|
|
||||||
};
|
|
||||||
|
|
||||||
+ (NSArray *)schemaCreationStatementsForEntities: (NSArray *)entities
|
|
||||||
options: (NSDictionary *)options
|
|
||||||
{
|
|
||||||
NSMutableArray *array = [NSMutableArray arrayWithCapacity: 5];
|
|
||||||
NSMutableArray *groups = [NSMutableArray arrayWithCapacity: 5];
|
|
||||||
NSMutableArray *group;
|
|
||||||
NSString *externalName;
|
|
||||||
EOEntity *entity;
|
|
||||||
int i, h, count;
|
|
||||||
struct _schema defaults[] = {
|
|
||||||
{EODropPrimaryKeySupportKey , @"YES",
|
|
||||||
@selector(dropPrimaryKeySupportStatementsForEntityGroups:)},
|
|
||||||
{EODropTablesKey , @"YES",
|
|
||||||
@selector(dropTableStatementsForEntityGroups:)},
|
|
||||||
{EODropDatabaseKey , @"NO",
|
|
||||||
@selector(_dropDatabaseStatementsForEntityGroups:)},
|
|
||||||
{EOCreateDatabaseKey , @"NO",
|
|
||||||
@selector(_createDatabaseStatementsForEntityGroups:)},
|
|
||||||
{EOCreateTablesKey , @"YES",
|
|
||||||
@selector(createTableStatementsForEntityGroups:)},
|
|
||||||
{EOCreatePrimaryKeySupportKey, @"YES",
|
|
||||||
@selector(primaryKeySupportStatementsForEntityGroups:)},
|
|
||||||
{EOPrimaryKeyConstraintsKey , @"YES",
|
|
||||||
@selector(primaryKeyConstraintStatementsForEntityGroups:)},
|
|
||||||
{EOForeignKeyConstraintsKey , @"NO",
|
|
||||||
@selector(foreignKeyConstraintStatementsForEntityGroups:)},
|
|
||||||
{nil, nil},
|
|
||||||
}; // Order is important!
|
|
||||||
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
count = [entities count];
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
entity = [entities objectAtIndex: i];
|
|
||||||
externalName = [entity externalName];
|
|
||||||
|
|
||||||
group = [NSMutableArray arrayWithCapacity: 1];
|
|
||||||
[groups addObject: group];
|
|
||||||
[group addObject: entity];
|
|
||||||
|
|
||||||
for (h = i + 1; h < count; h++)
|
|
||||||
{
|
|
||||||
if ([[[entities objectAtIndex: h] externalName]
|
|
||||||
isEqual: externalName])
|
|
||||||
[group addObject: [entities objectAtIndex: h]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; defaults[i].key != nil; i++)
|
|
||||||
{
|
|
||||||
NSString *value;
|
|
||||||
|
|
||||||
value = [options objectForKey: defaults[i].key];
|
|
||||||
|
|
||||||
if (!value)
|
|
||||||
value = defaults[i].value;
|
|
||||||
|
|
||||||
if ([value isEqual: @"YES"] == YES)
|
|
||||||
{
|
|
||||||
NSArray *stmts;
|
|
||||||
stmts = [self performSelector: defaults[i].selector
|
|
||||||
withObject: groups];
|
|
||||||
[array addObjectsFromArray: stmts];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *)columnTypeStringForAttribute:(EOAttribute *)attribute
|
|
||||||
{
|
|
||||||
NSString *extType = [attribute externalType];
|
|
||||||
int precision = [attribute precision];
|
|
||||||
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
if (precision)
|
|
||||||
{
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
return [NSString stringWithFormat:@"%@(%d, %d)", extType, precision,
|
|
||||||
[attribute scale]];
|
|
||||||
}
|
|
||||||
else if ([attribute width])
|
|
||||||
{
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
return [NSString stringWithFormat: @"%@(%d)",
|
|
||||||
extType, [attribute width]];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
return [NSString stringWithFormat: @"%@", extType];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *)allowsNullClauseForConstraint: (BOOL)allowsNull
|
|
||||||
{
|
|
||||||
if (allowsNull == NO)
|
|
||||||
return @"NOT NULL";
|
|
||||||
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)addCreateClauseForAttribute: (EOAttribute *)attribute
|
|
||||||
{
|
|
||||||
NSString *columnType;
|
|
||||||
NSString *allowsNull;
|
|
||||||
NSString *str;
|
|
||||||
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
columnType = [self columnTypeStringForAttribute: attribute];
|
|
||||||
allowsNull = [self allowsNullClauseForConstraint: [attribute allowsNull]];
|
|
||||||
|
|
||||||
if (allowsNull)
|
|
||||||
str = [NSString stringWithFormat: @"%@ %@ %@", [attribute columnName],
|
|
||||||
columnType, allowsNull];
|
|
||||||
else
|
|
||||||
str = [NSString stringWithFormat: @"%@ %@", [attribute columnName],
|
|
||||||
columnType];
|
|
||||||
|
|
||||||
[self appendItem:str toListString: /*_listString*/[self listString]]; // Else no chance to get inited (lazy)
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)prepareConstraintStatementForRelationship: (EORelationship *)relationship
|
|
||||||
sourceColumns: (NSArray *)sourceColumns
|
|
||||||
destinationColumns: (NSArray *)destinationColumns
|
|
||||||
{
|
|
||||||
NSMutableString *sourceString, *destinationString;
|
|
||||||
NSEnumerator *attrEnum;
|
|
||||||
EOAttribute *attr;
|
|
||||||
NSString *name, *str, *tableName, *relTableName;
|
|
||||||
BOOL first = YES;
|
|
||||||
|
|
||||||
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
|
||||||
|
|
||||||
name = [NSString stringWithFormat: @"%@_%@_FK", [_entity externalName],
|
|
||||||
[relationship name]];
|
|
||||||
|
|
||||||
sourceString = [NSMutableString stringWithCapacity: 30];
|
|
||||||
|
|
||||||
attrEnum = [sourceColumns objectEnumerator];
|
|
||||||
while ((attr = [attrEnum nextObject]))
|
|
||||||
{
|
|
||||||
NSString *columnName = [attr columnName];
|
|
||||||
|
|
||||||
if (!columnName || ![columnName length])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (first == NO)
|
|
||||||
[sourceString appendString: @", "];
|
|
||||||
|
|
||||||
[sourceString appendString: columnName];
|
|
||||||
first = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
first = YES;
|
|
||||||
destinationString = [NSMutableString stringWithCapacity: 30];
|
|
||||||
|
|
||||||
attrEnum = [destinationColumns objectEnumerator];
|
|
||||||
while ((attr = [attrEnum nextObject]))
|
|
||||||
{
|
|
||||||
NSString *columnName = [attr columnName];
|
|
||||||
|
|
||||||
if (!columnName || ![columnName length])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (first == NO)
|
|
||||||
[destinationString appendString: @", "];
|
|
||||||
|
|
||||||
[destinationString appendString: columnName];
|
|
||||||
first = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
tableName = [_entity externalName];
|
|
||||||
tableName = [self sqlStringForSchemaObjectName: tableName];
|
|
||||||
|
|
||||||
relTableName = [[relationship destinationEntity] externalName];
|
|
||||||
relTableName = [self sqlStringForSchemaObjectName: relTableName];
|
|
||||||
|
|
||||||
str = [NSString stringWithFormat: @"ALTER TABLE %@ ADD CONSTRAINT %@ "
|
|
||||||
@"FOREIGN KEY (%@) REFERENCES %@ (%@)",
|
|
||||||
tableName,
|
|
||||||
name,
|
|
||||||
sourceString,
|
|
||||||
relTableName,
|
|
||||||
destinationString];
|
|
||||||
|
|
||||||
ASSIGN(_statement, str);
|
|
||||||
|
|
||||||
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assembles an adaptor specific constraint statement for relationship.
|
|
||||||
|
|
||||||
+ (NSArray *)createDatabaseStatementsForConnectionDictionary: (NSDictionary *)connectionDictionary
|
|
||||||
administrativeConnectionDictionary: (NSDictionary *)administrativeConnectionDictionary
|
|
||||||
{
|
|
||||||
[self subclassResponsibility: _cmd];
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray *)dropDatabaseStatementsForConnectionDictionary: (NSDictionary *)connectionDictionary
|
|
||||||
administrativeConnectionDictionary: (NSDictionary *)administrativeConnectionDictionary
|
|
||||||
{
|
|
||||||
[self subclassResponsibility: _cmd];
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (EOSQLExpression *)selectStatementForContainerOptions
|
|
||||||
{
|
|
||||||
[self notImplemented: _cmd];
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/* -*-objc-*-
|
||||||
EOSchemaGeneration.h
|
EOSchemaGeneration.h
|
||||||
|
|
||||||
Copyright (C) 2004,2005 Free Software Foundation, Inc.
|
Copyright (C) 2004,2005 Free Software Foundation, Inc.
|
||||||
|
@ -32,75 +32,100 @@
|
||||||
|
|
||||||
@interface EOSQLExpression (EOSchemaGeneration)
|
@interface EOSQLExpression (EOSchemaGeneration)
|
||||||
|
|
||||||
/** Generates the statements to create a database **/
|
/**
|
||||||
+ (NSArray *)createDatabaseStatementsForConnectionDictionary:(NSDictionary *)connectionDictionary administrativeConnectionDictionary:(NSDictionary *)administrativeConnectionDictionary;
|
* Generates the statements to create a database.
|
||||||
|
*/
|
||||||
|
+ (NSArray *)createDatabaseStatementsForConnectionDictionary:(NSDictionary *)connectionDictionary
|
||||||
|
administrativeConnectionDictionary:(NSDictionary *)administrativeConnectionDictionary;
|
||||||
|
|
||||||
/** Generates the statements to drop the database **/
|
/**
|
||||||
+ (NSArray *)dropDatabaseStatementsForConnectionDictionary:(NSDictionary *)connectionDictionary administrativeConnectionDictionary:(NSDictionary *)administrativeConnectionDictionary;
|
* Generates the statements to drop the database.
|
||||||
|
*/
|
||||||
|
+ (NSArray *)dropDatabaseStatementsForConnectionDictionary:(NSDictionary *)connectionDictionary
|
||||||
|
administrativeConnectionDictionary:(NSDictionary *)administrativeConnectionDictionary;
|
||||||
|
|
||||||
/** Generates the statements necessary to implement the schema generation for
|
/** Generates the statements necessary to implement the schema generation for
|
||||||
an entityGroup like creating/dropping a table, a primary key constaint or
|
* an entityGroup like creating/dropping a table, a primary key constaint or
|
||||||
a primary key generation support such as a sequence. **/
|
* a primary key generation support such as a sequence.
|
||||||
|
*/
|
||||||
+ (NSArray *)createTableStatementsForEntityGroup: (NSArray *)entityGroup;
|
+ (NSArray *)createTableStatementsForEntityGroup: (NSArray *)entityGroup;
|
||||||
+ (NSArray *)dropTableStatementsForEntityGroup: (NSArray *)entityGroup;
|
+ (NSArray *)dropTableStatementsForEntityGroup: (NSArray *)entityGroup;
|
||||||
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroup: (NSArray *)entityGroup;
|
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroup: (NSArray *)entityGroup;
|
||||||
+ (NSArray *)primaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup;
|
+ (NSArray *)primaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup;
|
||||||
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup;
|
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup;
|
||||||
|
|
||||||
/** Generates statements to create/drop a specific schema generation for a
|
/**
|
||||||
list of entityGroups. **/
|
* Generates statements to create/drop a specific schema generation for a
|
||||||
|
* list of entityGroups.
|
||||||
|
*/
|
||||||
+ (NSArray *)createTableStatementsForEntityGroups: (NSArray *)entityGroups;
|
+ (NSArray *)createTableStatementsForEntityGroups: (NSArray *)entityGroups;
|
||||||
+ (NSArray *)dropTableStatementsForEntityGroups: (NSArray *)entityGroups;
|
+ (NSArray *)dropTableStatementsForEntityGroups: (NSArray *)entityGroups;
|
||||||
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroups: (NSArray *)entityGroups;
|
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroups: (NSArray *)entityGroups;
|
||||||
+ (NSArray *)primaryKeySupportStatementsForEntityGroups: (NSArray *)entityGroups;
|
+ (NSArray *)primaryKeySupportStatementsForEntityGroups: (NSArray *)entityGroups;
|
||||||
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroups: (NSArray *)entityGroups;
|
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroups: (NSArray *)entityGroups;
|
||||||
|
|
||||||
/** The default implementation verifies the relationship joins and calls
|
/**
|
||||||
+prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:
|
* The default implementation verifies the relationship joins and calls
|
||||||
**/
|
* prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:
|
||||||
|
*/
|
||||||
+ (NSArray *)foreignKeyConstraintStatementsForRelationship: (EORelationship *)relationship;
|
+ (NSArray *)foreignKeyConstraintStatementsForRelationship: (EORelationship *)relationship;
|
||||||
|
|
||||||
/** Assembles an adaptor specific string for using in a create table
|
/**
|
||||||
statement. **/
|
* Assembles an adaptor specific string for using in a create table
|
||||||
|
* statement.
|
||||||
|
*/
|
||||||
- (NSString *)columnTypeStringForAttribute: (EOAttribute *)attribute;
|
- (NSString *)columnTypeStringForAttribute: (EOAttribute *)attribute;
|
||||||
|
|
||||||
/** Generates a string to be used in a create table statement **/
|
/**
|
||||||
|
* Generates a string to be used in a create table statement
|
||||||
|
*/
|
||||||
- (NSString *)allowsNullClauseForConstraint: (BOOL)allowsNull;
|
- (NSString *)allowsNullClauseForConstraint: (BOOL)allowsNull;
|
||||||
|
|
||||||
/** Assembles the create table statement for the given attribute **/
|
/**
|
||||||
|
* Assembles the create table statement for the given attribute
|
||||||
|
*/
|
||||||
- (void)addCreateClauseForAttribute: (EOAttribute *)attribute;
|
- (void)addCreateClauseForAttribute: (EOAttribute *)attribute;
|
||||||
|
|
||||||
/** Assembles an adaptor specific constraint statement for relationship and the
|
/**
|
||||||
given source and destination columns **/
|
* Assembles an adaptor specific constraint statement for relationship and the
|
||||||
|
* given source and destination columns
|
||||||
|
*/
|
||||||
- (void)prepareConstraintStatementForRelationship: (EORelationship *)relationship
|
- (void)prepareConstraintStatementForRelationship: (EORelationship *)relationship
|
||||||
sourceColumns: (NSArray *)sourceColumns
|
sourceColumns: (NSArray *)sourceColumns
|
||||||
destinationColumns: (NSArray *)destinationColumns;
|
destinationColumns: (NSArray *)destinationColumns;
|
||||||
|
|
||||||
/** Append expression statement to an executable script.
|
/**
|
||||||
The default implementation appends the ';' **/
|
* Append expression statement to an executable script.
|
||||||
|
* The default implementation appends the ';'
|
||||||
|
*/
|
||||||
+ (void)appendExpression:(EOSQLExpression *)expression toScript:(NSMutableString *)script;
|
+ (void)appendExpression:(EOSQLExpression *)expression toScript:(NSMutableString *)script;
|
||||||
|
|
||||||
/** Returns a script to create the schema for the given entities specific for
|
/**
|
||||||
the target db. Options are the same as
|
* Returns a script to create the schema for the given entities specific for
|
||||||
-schemaCreationStatementsForEntities:options: **/
|
* the target db. Options are the same as
|
||||||
|
* [+schemaCreationStatementsForEntities:options:]
|
||||||
|
*/
|
||||||
+ (NSString *)schemaCreationScriptForEntities:(NSArray *)entities
|
+ (NSString *)schemaCreationScriptForEntities:(NSArray *)entities
|
||||||
options:(NSDictionary *)options;
|
options:(NSDictionary *)options;
|
||||||
|
|
||||||
/** Returns an array of EOSQLExpression suitable to create the schema for the
|
/**
|
||||||
given entities specific for the target db.
|
* <p>
|
||||||
Possible options are:
|
* Returns an array of EOSQLExpression suitable to create the schema for the
|
||||||
|
* given entities specific for the target db.
|
||||||
Name Value Default
|
* Possible options are:</p>
|
||||||
|
* <list>
|
||||||
createTables YES/NO YES
|
* <item>Name Value Default</item>
|
||||||
dropTables YES/NO YES
|
* <item></item>
|
||||||
createPrimaryKeySupport YES/NO YES
|
* <item>createTables YES/NO YES</item>
|
||||||
dropPrimaryKeySupport YES/NO YES
|
* <item>dropTables YES/NO YES</item>
|
||||||
primaryKeyConstraints YES/NO YES
|
* <item>createPrimaryKeySupport YES/NO YES</item>
|
||||||
foreignKeyConstraints YES/NO NO
|
* <item>dropPrimaryKeySupport YES/NO YES</item>
|
||||||
createDatabase YES/NO NO
|
* <item>primaryKeyConstraints YES/NO YES</item>
|
||||||
dropDatabase YES/NO NO
|
* <item>foreignKeyConstraints YES/NO NO</item>
|
||||||
**/
|
* <item>createDatabase YES/NO NO</item>
|
||||||
|
* <item>dropDatabase YES/NO NO</item>
|
||||||
|
* </list>
|
||||||
|
*/
|
||||||
+ (NSArray *)schemaCreationStatementsForEntities: (NSArray *)entities
|
+ (NSArray *)schemaCreationStatementsForEntities: (NSArray *)entities
|
||||||
options: (NSDictionary *)options;
|
options: (NSDictionary *)options;
|
||||||
|
|
||||||
|
@ -110,10 +135,9 @@
|
||||||
|
|
||||||
|
|
||||||
/** Keys to use the options dictionary for
|
/** Keys to use the options dictionary for
|
||||||
+schemaCreationScriptForEntities:options:
|
* +schemaCreationScriptForEntities:options:
|
||||||
and +schemaCreationStatementsForEntities:options: **/
|
* and +schemaCreationStatementsForEntities:options:
|
||||||
|
*/
|
||||||
|
|
||||||
GDL2ACCESS_EXPORT NSString *EOCreateTablesKey;
|
GDL2ACCESS_EXPORT NSString *EOCreateTablesKey;
|
||||||
GDL2ACCESS_EXPORT NSString *EODropTablesKey;
|
GDL2ACCESS_EXPORT NSString *EODropTablesKey;
|
||||||
GDL2ACCESS_EXPORT NSString *EOCreatePrimaryKeySupportKey;
|
GDL2ACCESS_EXPORT NSString *EOCreatePrimaryKeySupportKey;
|
||||||
|
|
865
EOAccess/EOSchemaGeneration.m
Normal file
865
EOAccess/EOSchemaGeneration.m
Normal file
|
@ -0,0 +1,865 @@
|
||||||
|
/**
|
||||||
|
EOSchemaGeneration.m <title>EOSchemaGeneration Class</title>
|
||||||
|
|
||||||
|
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: David Ayers <ayers@fsfe.org>
|
||||||
|
Date: February 2006
|
||||||
|
|
||||||
|
$Revision: 23653 $
|
||||||
|
$Date: 2006-09-28 17:25:30 +0200 (Don, 28 Sep 2006) $
|
||||||
|
|
||||||
|
<abstract></abstract>
|
||||||
|
|
||||||
|
This file is part of the GNUstep Database Library.
|
||||||
|
|
||||||
|
<license>
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; see the file COPYING.LIB.
|
||||||
|
If not, write to the Free Software Foundation,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
</license>
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
RCS_ID("$Id: EOSchemaGeneration.m 23653 2006-09-28 15:25:30Z ratmice $")
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef GNUSTEP
|
||||||
|
#include <Foundation/NSString.h>
|
||||||
|
#include <Foundation/NSNotification.h>
|
||||||
|
#else
|
||||||
|
#include <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef GNUSTEP
|
||||||
|
#include <GNUstepBase/GNUstep.h>
|
||||||
|
#include <GNUstepBase/GSObjCRuntime.h>
|
||||||
|
#include <GNUstepBase/GSCategories.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <EOControl/EODebug.h>
|
||||||
|
|
||||||
|
#include <EOAccess/EOModel.h>
|
||||||
|
#include <EOAccess/EOEntity.h>
|
||||||
|
#include <EOAccess/EOAttribute.h>
|
||||||
|
#include <EOAccess/EORelationship.h>
|
||||||
|
#include <EOAccess/EOAdaptor.h>
|
||||||
|
#include <EOAccess/EOAdaptorContext.h>
|
||||||
|
#include <EOAccess/EOAdaptorChannel.h>
|
||||||
|
#include <EOAccess/EOJoin.h>
|
||||||
|
#include <EOAccess/EOSchemaGeneration.h>
|
||||||
|
|
||||||
|
NSString *EOCreateTablesKey = @"EOCreateTablesKey";
|
||||||
|
NSString *EODropTablesKey = @"EODropTablesKey";
|
||||||
|
NSString *EOCreatePrimaryKeySupportKey = @"EOCreatePrimaryKeySupportKey";
|
||||||
|
NSString *EODropPrimaryKeySupportKey = @"EODropPrimaryKeySupportKey";
|
||||||
|
NSString *EOPrimaryKeyConstraintsKey = @"EOPrimaryKeyConstraintsKey";
|
||||||
|
NSString *EOForeignKeyConstraintsKey = @"EOForeignKeyConstraintsKey";
|
||||||
|
NSString *EOCreateDatabaseKey = @"EOCreateDatabaseKey";
|
||||||
|
NSString *EODropDatabaseKey = @"EODropDatabaseKey";
|
||||||
|
|
||||||
|
|
||||||
|
@implementation EOSQLExpression (EOSchemaGeneration)
|
||||||
|
|
||||||
|
+ (NSArray *)_administrativeDatabaseStatementsForSelector:(SEL) sel
|
||||||
|
forEntityGroup:(NSArray *)group
|
||||||
|
{
|
||||||
|
EOEntity *entity;
|
||||||
|
EOModel *model;
|
||||||
|
NSDictionary *connDict;
|
||||||
|
NSDictionary *admDict;
|
||||||
|
NSArray *stmts;
|
||||||
|
NSString *notifName;
|
||||||
|
NSMutableDictionary *notifDict;
|
||||||
|
|
||||||
|
entity = [group lastObject];
|
||||||
|
model = [entity model];
|
||||||
|
connDict = [model connectionDictionary];
|
||||||
|
|
||||||
|
notifDict = (id)[NSMutableDictionary dictionaryWithCapacity: 2];
|
||||||
|
[notifDict setObject: model forKey: EOModelKey];
|
||||||
|
notifName = EOAdministrativeConnectionDictionaryNeededNotification;
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName: notifName
|
||||||
|
object: notifDict];
|
||||||
|
admDict = [notifDict objectForKey: EOAdministrativeConnectionDictionaryKey];
|
||||||
|
/* TODO: ayers
|
||||||
|
if (admDict == nil && [admDict count] == 0)
|
||||||
|
{
|
||||||
|
EOAdaptor *adaptor;
|
||||||
|
EOLoginPanel *panel;
|
||||||
|
|
||||||
|
adaptor = [EOAdaptor adaptorWithModel: model];
|
||||||
|
panel = [[adaptor class] sharedLoginPanelInstance];
|
||||||
|
admDict = [panel administrativeConnectionDictionaryForAdaptor: adaptor];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
stmts = [self performSelector: sel
|
||||||
|
withObject: connDict
|
||||||
|
withObject: admDict];
|
||||||
|
|
||||||
|
return stmts;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)_dropDatabaseStatementsForEntityGroups: (NSArray *)entityGroups
|
||||||
|
{
|
||||||
|
NSMutableArray *cumStmts;
|
||||||
|
NSArray *stmts;
|
||||||
|
NSArray *group;
|
||||||
|
unsigned i,n;
|
||||||
|
SEL sel;
|
||||||
|
|
||||||
|
sel = @selector(dropDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:);
|
||||||
|
|
||||||
|
n = [entityGroups count];
|
||||||
|
cumStmts = [NSMutableArray arrayWithCapacity: n];
|
||||||
|
|
||||||
|
for (i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
EOSQLExpression *expr;
|
||||||
|
unsigned j,m;
|
||||||
|
|
||||||
|
group = [entityGroups objectAtIndex: i];
|
||||||
|
stmts = [self _administrativeDatabaseStatementsForSelector: sel
|
||||||
|
forEntityGroup: group];
|
||||||
|
for (j=0, m=[stmts count]; j<m; j++)
|
||||||
|
{
|
||||||
|
NSArray *rawStmts;
|
||||||
|
NSString *stmt;
|
||||||
|
|
||||||
|
rawStmts = [cumStmts valueForKey:@"statement"];
|
||||||
|
expr = [stmts objectAtIndex: j];
|
||||||
|
stmt = [expr statement];
|
||||||
|
|
||||||
|
if ([rawStmts containsObject: stmt] == NO)
|
||||||
|
{
|
||||||
|
[cumStmts addObject: expr];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [NSArray arrayWithArray: cumStmts];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)_createDatabaseStatementsForEntityGroups: (NSArray *)entityGroups
|
||||||
|
{
|
||||||
|
NSMutableArray *cumStmts;
|
||||||
|
NSArray *stmts;
|
||||||
|
NSArray *group;
|
||||||
|
unsigned i,n;
|
||||||
|
SEL sel;
|
||||||
|
|
||||||
|
sel = @selector(createDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:);
|
||||||
|
|
||||||
|
n = [entityGroups count];
|
||||||
|
cumStmts = [NSMutableArray arrayWithCapacity: n];
|
||||||
|
|
||||||
|
for (i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
EOSQLExpression *expr;
|
||||||
|
unsigned j,m;
|
||||||
|
|
||||||
|
group = [entityGroups objectAtIndex: i];
|
||||||
|
stmts = [self _administrativeDatabaseStatementsForSelector: sel
|
||||||
|
forEntityGroup: group];
|
||||||
|
|
||||||
|
for (j=0, m=[stmts count]; j<m; j++)
|
||||||
|
{
|
||||||
|
NSArray *rawStmts;
|
||||||
|
NSString *stmt;
|
||||||
|
|
||||||
|
rawStmts = [cumStmts valueForKey:@"statement"];
|
||||||
|
expr = [stmts objectAtIndex: j];
|
||||||
|
stmt = [expr statement];
|
||||||
|
|
||||||
|
if ([rawStmts containsObject: stmt] == NO)
|
||||||
|
{
|
||||||
|
[cumStmts addObject: expr];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [NSArray arrayWithArray: cumStmts];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)foreignKeyConstraintStatementsForRelationship: (EORelationship *)relationship
|
||||||
|
{
|
||||||
|
NSMutableArray *array, *sourceColumns, *destColumns;
|
||||||
|
EOSQLExpression *sqlExpression;
|
||||||
|
EOEntity *entity;
|
||||||
|
NSEnumerator *joinEnum;
|
||||||
|
EOJoin *join;
|
||||||
|
unsigned num;
|
||||||
|
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
array = [NSMutableArray arrayWithCapacity: 1];
|
||||||
|
|
||||||
|
if ([[relationship entity] model]
|
||||||
|
!= [[relationship destinationEntity] model])
|
||||||
|
{
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([relationship isToMany] == YES
|
||||||
|
|| ([relationship inverseRelationship] != nil
|
||||||
|
&& [[relationship inverseRelationship] isToMany] == NO))
|
||||||
|
{
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
entity = [relationship entity];
|
||||||
|
sqlExpression = [self sqlExpressionWithEntity: entity];
|
||||||
|
|
||||||
|
num = [[relationship joins] count];
|
||||||
|
|
||||||
|
sourceColumns = [NSMutableArray arrayWithCapacity: num];
|
||||||
|
destColumns = [NSMutableArray arrayWithCapacity: num];
|
||||||
|
|
||||||
|
joinEnum = [[relationship joins] objectEnumerator];
|
||||||
|
while ((join = [joinEnum nextObject]))
|
||||||
|
{
|
||||||
|
[sourceColumns addObject: [join sourceAttribute]];
|
||||||
|
[destColumns addObject: [join destinationAttribute]];
|
||||||
|
}
|
||||||
|
|
||||||
|
[sqlExpression prepareConstraintStatementForRelationship: relationship
|
||||||
|
sourceColumns: sourceColumns
|
||||||
|
destinationColumns: destColumns];
|
||||||
|
|
||||||
|
[array addObject: sqlExpression];
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)foreignKeyConstraintStatementsForEntityGroup:(NSArray *)entityGroup
|
||||||
|
{
|
||||||
|
NSMutableArray *sqlExps;
|
||||||
|
EORelationship *rel;
|
||||||
|
EOEntity *entity;
|
||||||
|
EOEntity *parentEntity;
|
||||||
|
unsigned i,j,n,m;
|
||||||
|
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
sqlExps = [NSMutableArray array];
|
||||||
|
|
||||||
|
for (i=0, n=[entityGroup count]; i<n; i++)
|
||||||
|
{
|
||||||
|
NSArray *rels;
|
||||||
|
|
||||||
|
entity = [entityGroup objectAtIndex: i];
|
||||||
|
parentEntity = [entity parentEntity];
|
||||||
|
rels = [entity relationships];
|
||||||
|
|
||||||
|
for (j=0, m=[rels count]; parentEntity == nil && j<m; j++)
|
||||||
|
{
|
||||||
|
NSArray *stmts;
|
||||||
|
|
||||||
|
rel = [rels objectAtIndex: j];
|
||||||
|
stmts =[self foreignKeyConstraintStatementsForRelationship: rel];
|
||||||
|
[sqlExps addObjectsFromArray: stmts];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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]))
|
||||||
|
{
|
||||||
|
NSArray *stmts;
|
||||||
|
|
||||||
|
stmts = [self foreignKeyConstraintStatementsForEntityGroup: group];
|
||||||
|
[array addObjectsFromArray: stmts];
|
||||||
|
}
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
// default implementation verifies that relationship joins on foreign key
|
||||||
|
// of destination and calls
|
||||||
|
// prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:
|
||||||
|
|
||||||
|
+ (NSArray *)createTableStatementsForEntityGroup: (NSArray *)entityGroup
|
||||||
|
{
|
||||||
|
EOSQLExpression *sqlExp;
|
||||||
|
NSEnumerator *entityEnum, *attrEnum;
|
||||||
|
EOAttribute *attr;
|
||||||
|
EOEntity *entity;
|
||||||
|
NSString *tableName;
|
||||||
|
NSString *stmt;
|
||||||
|
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
if ([[entityGroup objectAtIndex:0] isAbstractEntity])
|
||||||
|
return [NSArray array];
|
||||||
|
|
||||||
|
sqlExp = [self sqlExpressionWithEntity:[entityGroup objectAtIndex: 0]];
|
||||||
|
|
||||||
|
entityEnum = [entityGroup objectEnumerator];
|
||||||
|
while ((entity = [entityEnum nextObject]))
|
||||||
|
{
|
||||||
|
attrEnum = [[entity attributes] objectEnumerator];
|
||||||
|
|
||||||
|
while ((attr = [attrEnum nextObject]))
|
||||||
|
[sqlExp addCreateClauseForAttribute: attr];
|
||||||
|
}
|
||||||
|
|
||||||
|
entity = [entityGroup objectAtIndex: 0];
|
||||||
|
tableName = [entity externalName];
|
||||||
|
tableName = [sqlExp sqlStringForSchemaObjectName: tableName];
|
||||||
|
|
||||||
|
stmt = [NSString stringWithFormat: @"CREATE TABLE %@ (%@)",
|
||||||
|
tableName,
|
||||||
|
[sqlExp listString]];
|
||||||
|
[sqlExp setStatement: stmt];
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return [NSArray arrayWithObject: sqlExp];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)dropTableStatementsForEntityGroup:(NSArray *)entityGroup
|
||||||
|
{
|
||||||
|
NSArray *newArray;
|
||||||
|
NSString *tableName;
|
||||||
|
EOEntity *entity;
|
||||||
|
NSString *stmt;
|
||||||
|
EOSQLExpression *sqlExp;
|
||||||
|
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
entity = [entityGroup objectAtIndex: 0];
|
||||||
|
|
||||||
|
if ([entity isAbstractEntity])
|
||||||
|
return [NSArray array];
|
||||||
|
|
||||||
|
sqlExp = [self sqlExpressionWithEntity: entity];
|
||||||
|
tableName = [entity externalName];
|
||||||
|
tableName = [sqlExp sqlStringForSchemaObjectName: tableName];
|
||||||
|
|
||||||
|
stmt = [NSString stringWithFormat: @"DROP TABLE %@", tableName];
|
||||||
|
[sqlExp setStatement: stmt];
|
||||||
|
newArray = [NSArray arrayWithObject: sqlExp];
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return newArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroup:(NSArray *)entityGroup
|
||||||
|
{
|
||||||
|
EOSQLExpression *sqlExp;
|
||||||
|
NSMutableString *listString;
|
||||||
|
NSEnumerator *attrEnum;
|
||||||
|
EOAttribute *attr;
|
||||||
|
EOEntity *entity;
|
||||||
|
NSString *tableName;
|
||||||
|
NSString *stmt;
|
||||||
|
BOOL first = YES;
|
||||||
|
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
entity = [entityGroup objectAtIndex: 0];
|
||||||
|
listString = [NSMutableString stringWithCapacity: 30];
|
||||||
|
|
||||||
|
attrEnum = [[entity primaryKeyAttributes] objectEnumerator];
|
||||||
|
while ((attr = [attrEnum nextObject]))
|
||||||
|
{
|
||||||
|
NSString *columnName = [attr columnName];
|
||||||
|
|
||||||
|
if (!columnName || ![columnName length])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (first == NO)
|
||||||
|
[listString appendString: @", "];
|
||||||
|
|
||||||
|
[listString appendString: columnName];
|
||||||
|
first = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (first == YES)
|
||||||
|
{
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return [NSArray array];
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlExp = [self sqlExpressionWithEntity:[entityGroup objectAtIndex: 0]];
|
||||||
|
tableName = [entity externalName];
|
||||||
|
tableName = [sqlExp sqlStringForSchemaObjectName: tableName];
|
||||||
|
|
||||||
|
stmt = [NSString stringWithFormat: @"ALTER TABLE %@ ADD PRIMARY KEY (%@)",
|
||||||
|
tableName, listString];
|
||||||
|
[sqlExp setStatement: stmt];
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return [NSArray arrayWithObject: sqlExp];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)primaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup
|
||||||
|
{
|
||||||
|
NSArray *newArray;
|
||||||
|
NSString *seqName;
|
||||||
|
EOEntity *entity;
|
||||||
|
NSString *pkRootName;
|
||||||
|
NSString *stmt;
|
||||||
|
EOSQLExpression *sqlExp;
|
||||||
|
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
entity = [entityGroup objectAtIndex: 0];
|
||||||
|
|
||||||
|
if ([entity isAbstractEntity])
|
||||||
|
return [NSArray array];
|
||||||
|
|
||||||
|
pkRootName = [entity primaryKeyRootName];
|
||||||
|
seqName = [NSString stringWithFormat: @"%@_SEQ", pkRootName];
|
||||||
|
|
||||||
|
sqlExp = [self sqlExpressionWithEntity: nil];
|
||||||
|
seqName = [sqlExp sqlStringForSchemaObjectName: seqName];
|
||||||
|
|
||||||
|
stmt = [NSString stringWithFormat: @"CREATE SEQUENCE %@", seqName];
|
||||||
|
[sqlExp setStatement: stmt];
|
||||||
|
newArray = [NSArray arrayWithObject: sqlExp];
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return newArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup
|
||||||
|
{
|
||||||
|
NSArray *newArray;
|
||||||
|
NSString *seqName;
|
||||||
|
EOEntity *entity;
|
||||||
|
NSString *pkRootName;
|
||||||
|
NSString *stmt;
|
||||||
|
EOSQLExpression *sqlExp;
|
||||||
|
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
entity = [entityGroup objectAtIndex: 0];
|
||||||
|
|
||||||
|
if ([entity isAbstractEntity])
|
||||||
|
return [NSArray array];
|
||||||
|
|
||||||
|
pkRootName = [entity primaryKeyRootName];
|
||||||
|
seqName = [NSString stringWithFormat: @"%@_SEQ", pkRootName];
|
||||||
|
|
||||||
|
sqlExp = [self sqlExpressionWithEntity: nil];
|
||||||
|
seqName = [sqlExp sqlStringForSchemaObjectName: seqName];
|
||||||
|
|
||||||
|
stmt = [NSString stringWithFormat: @"DROP SEQUENCE %@", seqName];
|
||||||
|
[sqlExp setStatement: stmt];
|
||||||
|
newArray = [NSArray arrayWithObject: sqlExp];
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return newArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)createTableStatementsForEntityGroups: (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 createTableStatementsForEntityGroup: group]];
|
||||||
|
}
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)dropTableStatementsForEntityGroups: (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 dropTableStatementsForEntityGroup: group]];
|
||||||
|
}
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroups: (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 primaryKeyConstraintStatementsForEntityGroup: group]];
|
||||||
|
}
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)primaryKeySupportStatementsForEntityGroups: (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 primaryKeySupportStatementsForEntityGroup: group]];
|
||||||
|
}
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroups: (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 dropPrimaryKeySupportStatementsForEntityGroup: group]];
|
||||||
|
}
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)appendExpression: (EOSQLExpression *)expression
|
||||||
|
toScript: (NSMutableString *)script
|
||||||
|
{
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
[script appendFormat:@"%@;\n", [expression statement]];
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
+ (NSString *)schemaCreationScriptForEntities: (NSArray *)entities
|
||||||
|
options: (NSDictionary *)options
|
||||||
|
{
|
||||||
|
NSMutableString *script = [NSMutableString stringWithCapacity:50];
|
||||||
|
NSEnumerator *arrayEnum;
|
||||||
|
EOSQLExpression *sqlExp;
|
||||||
|
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
arrayEnum = [[self schemaCreationStatementsForEntities: entities
|
||||||
|
options: options] objectEnumerator];
|
||||||
|
|
||||||
|
while ((sqlExp = [arrayEnum nextObject]))
|
||||||
|
[self appendExpression: sqlExp toScript: script];
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct _schema
|
||||||
|
{
|
||||||
|
NSString *key;
|
||||||
|
NSString *value;
|
||||||
|
SEL selector;
|
||||||
|
};
|
||||||
|
|
||||||
|
+ (NSArray *)schemaCreationStatementsForEntities: (NSArray *)entities
|
||||||
|
options: (NSDictionary *)options
|
||||||
|
{
|
||||||
|
NSMutableArray *array = [NSMutableArray arrayWithCapacity: 5];
|
||||||
|
NSMutableArray *groups = [NSMutableArray arrayWithCapacity: 5];
|
||||||
|
NSMutableArray *group;
|
||||||
|
NSString *externalName;
|
||||||
|
EOEntity *entity;
|
||||||
|
int i, h, count;
|
||||||
|
struct _schema defaults[] = {
|
||||||
|
{EODropPrimaryKeySupportKey , @"YES",
|
||||||
|
@selector(dropPrimaryKeySupportStatementsForEntityGroups:)},
|
||||||
|
{EODropTablesKey , @"YES",
|
||||||
|
@selector(dropTableStatementsForEntityGroups:)},
|
||||||
|
{EODropDatabaseKey , @"NO",
|
||||||
|
@selector(_dropDatabaseStatementsForEntityGroups:)},
|
||||||
|
{EOCreateDatabaseKey , @"NO",
|
||||||
|
@selector(_createDatabaseStatementsForEntityGroups:)},
|
||||||
|
{EOCreateTablesKey , @"YES",
|
||||||
|
@selector(createTableStatementsForEntityGroups:)},
|
||||||
|
{EOCreatePrimaryKeySupportKey, @"YES",
|
||||||
|
@selector(primaryKeySupportStatementsForEntityGroups:)},
|
||||||
|
{EOPrimaryKeyConstraintsKey , @"YES",
|
||||||
|
@selector(primaryKeyConstraintStatementsForEntityGroups:)},
|
||||||
|
{EOForeignKeyConstraintsKey , @"NO",
|
||||||
|
@selector(foreignKeyConstraintStatementsForEntityGroups:)},
|
||||||
|
{nil, nil},
|
||||||
|
}; // Order is important!
|
||||||
|
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
count = [entities count];
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
entity = [entities objectAtIndex: i];
|
||||||
|
externalName = [entity externalName];
|
||||||
|
|
||||||
|
group = [NSMutableArray arrayWithCapacity: 1];
|
||||||
|
[groups addObject: group];
|
||||||
|
[group addObject: entity];
|
||||||
|
|
||||||
|
for (h = i + 1; h < count; h++)
|
||||||
|
{
|
||||||
|
if ([[[entities objectAtIndex: h] externalName]
|
||||||
|
isEqual: externalName])
|
||||||
|
[group addObject: [entities objectAtIndex: h]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; defaults[i].key != nil; i++)
|
||||||
|
{
|
||||||
|
NSString *value;
|
||||||
|
|
||||||
|
value = [options objectForKey: defaults[i].key];
|
||||||
|
|
||||||
|
if (!value)
|
||||||
|
value = defaults[i].value;
|
||||||
|
|
||||||
|
if ([value isEqual: @"YES"] == YES)
|
||||||
|
{
|
||||||
|
NSArray *stmts;
|
||||||
|
stmts = [self performSelector: defaults[i].selector
|
||||||
|
withObject: groups];
|
||||||
|
[array addObjectsFromArray: stmts];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)columnTypeStringForAttribute:(EOAttribute *)attribute
|
||||||
|
{
|
||||||
|
NSString *extType = [attribute externalType];
|
||||||
|
int precision = [attribute precision];
|
||||||
|
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
if (precision)
|
||||||
|
{
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
return [NSString stringWithFormat:@"%@(%d, %d)", extType, precision,
|
||||||
|
[attribute scale]];
|
||||||
|
}
|
||||||
|
else if ([attribute width])
|
||||||
|
{
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
return [NSString stringWithFormat: @"%@(%d)",
|
||||||
|
extType, [attribute width]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
return [NSString stringWithFormat: @"%@", extType];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)allowsNullClauseForConstraint: (BOOL)allowsNull
|
||||||
|
{
|
||||||
|
if (allowsNull == NO)
|
||||||
|
return @"NOT NULL";
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)addCreateClauseForAttribute: (EOAttribute *)attribute
|
||||||
|
{
|
||||||
|
NSString *columnType;
|
||||||
|
NSString *allowsNull;
|
||||||
|
NSString *str;
|
||||||
|
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
columnType = [self columnTypeStringForAttribute: attribute];
|
||||||
|
allowsNull = [self allowsNullClauseForConstraint: [attribute allowsNull]];
|
||||||
|
|
||||||
|
if (allowsNull)
|
||||||
|
str = [NSString stringWithFormat: @"%@ %@ %@", [attribute columnName],
|
||||||
|
columnType, allowsNull];
|
||||||
|
else
|
||||||
|
str = [NSString stringWithFormat: @"%@ %@", [attribute columnName],
|
||||||
|
columnType];
|
||||||
|
|
||||||
|
[self appendItem:str toListString: /*_listString*/[self listString]]; // Else no chance to get inited (lazy)
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)prepareConstraintStatementForRelationship: (EORelationship *)relationship
|
||||||
|
sourceColumns: (NSArray *)sourceColumns
|
||||||
|
destinationColumns: (NSArray *)destinationColumns
|
||||||
|
{
|
||||||
|
NSMutableString *sourceString, *destinationString;
|
||||||
|
NSEnumerator *attrEnum;
|
||||||
|
EOAttribute *attr;
|
||||||
|
NSString *name, *str, *tableName, *relTableName;
|
||||||
|
BOOL first = YES;
|
||||||
|
|
||||||
|
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
|
||||||
|
|
||||||
|
name = [NSString stringWithFormat: @"%@_%@_FK", [_entity externalName],
|
||||||
|
[relationship name]];
|
||||||
|
|
||||||
|
sourceString = [NSMutableString stringWithCapacity: 30];
|
||||||
|
|
||||||
|
attrEnum = [sourceColumns objectEnumerator];
|
||||||
|
while ((attr = [attrEnum nextObject]))
|
||||||
|
{
|
||||||
|
NSString *columnName = [attr columnName];
|
||||||
|
|
||||||
|
if (!columnName || ![columnName length])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (first == NO)
|
||||||
|
[sourceString appendString: @", "];
|
||||||
|
|
||||||
|
[sourceString appendString: columnName];
|
||||||
|
first = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
first = YES;
|
||||||
|
destinationString = [NSMutableString stringWithCapacity: 30];
|
||||||
|
|
||||||
|
attrEnum = [destinationColumns objectEnumerator];
|
||||||
|
while ((attr = [attrEnum nextObject]))
|
||||||
|
{
|
||||||
|
NSString *columnName = [attr columnName];
|
||||||
|
|
||||||
|
if (!columnName || ![columnName length])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (first == NO)
|
||||||
|
[destinationString appendString: @", "];
|
||||||
|
|
||||||
|
[destinationString appendString: columnName];
|
||||||
|
first = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
tableName = [_entity externalName];
|
||||||
|
tableName = [self sqlStringForSchemaObjectName: tableName];
|
||||||
|
|
||||||
|
relTableName = [[relationship destinationEntity] externalName];
|
||||||
|
relTableName = [self sqlStringForSchemaObjectName: relTableName];
|
||||||
|
|
||||||
|
str = [NSString stringWithFormat: @"ALTER TABLE %@ ADD CONSTRAINT %@ "
|
||||||
|
@"FOREIGN KEY (%@) REFERENCES %@ (%@)",
|
||||||
|
tableName,
|
||||||
|
name,
|
||||||
|
sourceString,
|
||||||
|
relTableName,
|
||||||
|
destinationString];
|
||||||
|
|
||||||
|
ASSIGN(_statement, str);
|
||||||
|
|
||||||
|
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assembles an adaptor specific constraint statement for relationship.
|
||||||
|
|
||||||
|
+ (NSArray *)createDatabaseStatementsForConnectionDictionary: (NSDictionary *)connectionDictionary
|
||||||
|
administrativeConnectionDictionary: (NSDictionary *)administrativeConnectionDictionary
|
||||||
|
{
|
||||||
|
[self subclassResponsibility: _cmd];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)dropDatabaseStatementsForConnectionDictionary: (NSDictionary *)connectionDictionary
|
||||||
|
administrativeConnectionDictionary: (NSDictionary *)administrativeConnectionDictionary
|
||||||
|
{
|
||||||
|
[self subclassResponsibility: _cmd];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (EOSQLExpression *)selectStatementForContainerOptions
|
||||||
|
{
|
||||||
|
[self notImplemented: _cmd];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -49,41 +49,41 @@ GDL2ACCESS_EXPORT NSString *EOMoreThanOneException;
|
||||||
|
|
||||||
@interface EOEditingContext (EOUtilities)
|
@interface EOEditingContext (EOUtilities)
|
||||||
|
|
||||||
- (NSArray *)objectsForEntityNamed: (NSString *)name;
|
- (NSArray *)objectsForEntityNamed: (NSString *)entityName;
|
||||||
- (NSArray *)objectsOfClass: (Class)classObject;
|
- (NSArray *)objectsOfClass: (Class)classObject;
|
||||||
- (NSArray *)objectsWithFetchSpecificationNamed: (NSString *)fetchSpecName
|
- (NSArray *)objectsWithFetchSpecificationNamed: (NSString *)fetchSpecName
|
||||||
entityNamed: (NSString *)entityName
|
entityNamed: (NSString *)entityName
|
||||||
bindings: (NSDictionary *)bindings;
|
bindings: (NSDictionary *)bindings;
|
||||||
- (NSArray *)objectsForEntityNamed: (NSString *)name
|
- (NSArray *)objectsForEntityNamed: (NSString *)entityName
|
||||||
qualifierFormat: (NSString *)format, ...;
|
qualifierFormat: (NSString *)format, ...;
|
||||||
- (NSArray *)objectsMatchingValue: (id)value
|
- (NSArray *)objectsMatchingValue: (id)value
|
||||||
forKey: (NSString *)key
|
forKey: (NSString *)key
|
||||||
entityNamed: (NSString *)name;
|
entityNamed: (NSString *)entityName;
|
||||||
- (NSArray *)objectsMatchingValues: (NSDictionary *)values
|
- (NSArray *)objectsMatchingValues: (NSDictionary *)values
|
||||||
entityNamed: (NSString *)name;
|
entityNamed: (NSString *)entityName;
|
||||||
|
|
||||||
- (id)objectWithFetchSpecificationNamed: (NSString *)fetchSpecName
|
- (id)objectWithFetchSpecificationNamed: (NSString *)fetchSpecName
|
||||||
entityNamed: (NSString *)entityName
|
entityNamed: (NSString *)entityName
|
||||||
bindings: (NSDictionary *)bindings;
|
bindings: (NSDictionary *)bindings;
|
||||||
- (id)objectForEntityNamed: (NSString *)name
|
- (id)objectForEntityNamed: (NSString *)entityName
|
||||||
qualifierFormat: (NSString *)format, ...;
|
qualifierFormat: (NSString *)format, ...;
|
||||||
- (id)objectMatchingValue: (id)value
|
- (id)objectMatchingValue: (id)value
|
||||||
forKey: (NSString *)key
|
forKey: (NSString *)key
|
||||||
entityNamed: (NSString *)name;
|
entityNamed: (NSString *)entityName;
|
||||||
- (id)objectMatchingValues: (NSDictionary *)values
|
- (id)objectMatchingValues: (NSDictionary *)values
|
||||||
entityNamed: (NSString *)name;
|
entityNamed: (NSString *)entityName;
|
||||||
- (id)objectWithPrimaryKeyValue: (id)value
|
- (id)objectWithPrimaryKeyValue: (id)value
|
||||||
entityNamed: (NSString *)name;
|
entityNamed: (NSString *)entityName;
|
||||||
- (id)objectWithPrimaryKey: (NSDictionary *)pkDict
|
- (id)objectWithPrimaryKey: (NSDictionary *)pkDict
|
||||||
entityNamed: (NSString *)name;
|
entityNamed: (NSString *)entityName;
|
||||||
|
|
||||||
- (NSArray *)rawRowsForEntityNamed: (NSString *)name
|
- (NSArray *)rawRowsForEntityNamed: (NSString *)entityName
|
||||||
qualifierFormat: (NSString *)format, ...;
|
qualifierFormat: (NSString *)format, ...;
|
||||||
- (NSArray *)rawRowsMatchingValue: (id)value
|
- (NSArray *)rawRowsMatchingValue: (id)value
|
||||||
forKey: (NSString *)key
|
forKey: (NSString *)key
|
||||||
entityNamed: (NSString *)name;
|
entityNamed: (NSString *)entityName;
|
||||||
- (NSArray *)rawRowsMatchingValues: (NSDictionary *)values
|
- (NSArray *)rawRowsMatchingValues: (NSDictionary *)values
|
||||||
entityNamed: (NSString *)name;
|
entityNamed: (NSString *)entityName;
|
||||||
- (NSArray *)rawRowsWithSQL: (NSString *)sqlString
|
- (NSArray *)rawRowsWithSQL: (NSString *)sqlString
|
||||||
modelNamed: (NSString *)name;
|
modelNamed: (NSString *)name;
|
||||||
- (NSArray *)rawRowsWithStoredProcedureNamed: (NSString *)name
|
- (NSArray *)rawRowsWithStoredProcedureNamed: (NSString *)name
|
||||||
|
@ -91,7 +91,7 @@ GDL2ACCESS_EXPORT NSString *EOMoreThanOneException;
|
||||||
- (NSDictionary *)executeStoredProcedureNamed: (NSString *)name
|
- (NSDictionary *)executeStoredProcedureNamed: (NSString *)name
|
||||||
arguments: (NSDictionary *)args;
|
arguments: (NSDictionary *)args;
|
||||||
- (id)objectFromRawRow: (NSDictionary *)row
|
- (id)objectFromRawRow: (NSDictionary *)row
|
||||||
entityNamed: (NSString *)name;
|
entityNamed: (NSString *)entityName;
|
||||||
|
|
||||||
- (EODatabaseContext *)databaseContextForModelNamed: (NSString *)name;
|
- (EODatabaseContext *)databaseContextForModelNamed: (NSString *)name;
|
||||||
- (void)connectWithModelNamed: (NSString *)name
|
- (void)connectWithModelNamed: (NSString *)name
|
||||||
|
@ -107,9 +107,9 @@ connectionDictionaryOverrides: (NSDictionary *)overrides;
|
||||||
- (NSArray *)localInstancesOfObjects: (NSArray *)objects;
|
- (NSArray *)localInstancesOfObjects: (NSArray *)objects;
|
||||||
|
|
||||||
- (EOModelGroup *)modelGroup;
|
- (EOModelGroup *)modelGroup;
|
||||||
- (EOEntity *)entityNamed: (NSString *)name;
|
- (EOEntity *)entityNamed: (NSString *)entityName;
|
||||||
- (EOEntity *)entityForClass: (Class)classObject;
|
- (EOEntity *)entityForClass: (Class)classObject;
|
||||||
- (EOEntity *)entityForObject: (id)obj;
|
- (EOEntity *)entityForObject: (id)object;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -122,12 +122,4 @@ connectionDictionaryOverrides: (NSDictionary *)overrides;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@interface EOObjectStoreCoordinator (EOModelGroup)
|
|
||||||
|
|
||||||
- (id)modelGroup;
|
|
||||||
- (void)setModelGroup: (EOModelGroup *)modelGroup;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -758,7 +758,7 @@ NSString *NSObjectNotAvailableException = @"NSObjectNotAvailableException";
|
||||||
entityNamed: entityName];
|
entityNamed: entityName];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (EODatabaseContext *)databaseContextForModelNamed: (NSString *)name;
|
- (EODatabaseContext *)databaseContextForModelNamed: (NSString *)name
|
||||||
{
|
{
|
||||||
EOModelGroup *modelGroup;
|
EOModelGroup *modelGroup;
|
||||||
EOModel *model;
|
EOModel *model;
|
||||||
|
@ -816,7 +816,7 @@ connectionDictionaryOverrides: (NSDictionary *)overrides
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *)primaryKeyForObject: (id)object;
|
- (NSDictionary *)primaryKeyForObject: (id)object
|
||||||
{
|
{
|
||||||
EOKeyGlobalID *gid;
|
EOKeyGlobalID *gid;
|
||||||
EOEntity *entity;
|
EOEntity *entity;
|
||||||
|
@ -1094,53 +1094,3 @@ connectionDictionaryOverrides: (NSDictionary *)overrides
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@implementation EOObjectStoreCoordinator (EOModelGroup)
|
|
||||||
|
|
||||||
- (id)modelGroup
|
|
||||||
{
|
|
||||||
//Seems OK
|
|
||||||
EOModelGroup *modelGroup;
|
|
||||||
NSDictionary *userInfo;
|
|
||||||
|
|
||||||
EOFLOGObjectFnStart();
|
|
||||||
|
|
||||||
userInfo = [self userInfo];
|
|
||||||
modelGroup = [userInfo objectForKey: @"EOModelGroup"];
|
|
||||||
|
|
||||||
if (!modelGroup)
|
|
||||||
{
|
|
||||||
modelGroup = [EOModelGroup defaultGroup];
|
|
||||||
[self setModelGroup: modelGroup];
|
|
||||||
}
|
|
||||||
|
|
||||||
EOFLOGObjectFnStop();
|
|
||||||
|
|
||||||
return modelGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setModelGroup: (EOModelGroup *)modelGroup
|
|
||||||
{
|
|
||||||
NSMutableDictionary *userInfo;
|
|
||||||
|
|
||||||
EOFLOGObjectFnStart();
|
|
||||||
|
|
||||||
userInfo = (NSMutableDictionary *)[self userInfo];
|
|
||||||
|
|
||||||
if (userInfo)
|
|
||||||
[userInfo setObject: modelGroup
|
|
||||||
forKey: @"EOModelGroup"];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
userInfo = (id)[NSMutableDictionary dictionary];
|
|
||||||
|
|
||||||
[userInfo setObject: modelGroup
|
|
||||||
forKey: @"EOModelGroup"];
|
|
||||||
[self setUserInfo: userInfo];
|
|
||||||
}
|
|
||||||
|
|
||||||
EOFLOGObjectFnStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ EOAdaptorContext.m \
|
||||||
EOAdaptorChannel.m \
|
EOAdaptorChannel.m \
|
||||||
EOAdaptorOperation.m \
|
EOAdaptorOperation.m \
|
||||||
EODatabaseOperation.m \
|
EODatabaseOperation.m \
|
||||||
|
EOSchemaGeneration.m \
|
||||||
EOSQLExpression.m \
|
EOSQLExpression.m \
|
||||||
EOSQLQualifier.m \
|
EOSQLQualifier.m \
|
||||||
EODatabase.m \
|
EODatabase.m \
|
||||||
|
|
|
@ -3,6 +3,6 @@ GDL2_AGSDOC_FLAGS = \
|
||||||
-WordMap '{ \
|
-WordMap '{ \
|
||||||
RCS_ID = "//"; \
|
RCS_ID = "//"; \
|
||||||
GDL2CONTROL_EXPORT = extern; \
|
GDL2CONTROL_EXPORT = extern; \
|
||||||
|
GDL2ACCESS_EXPORT = extern; \
|
||||||
|
GDL2INTERFACE_EXPORT = extern; \
|
||||||
}'
|
}'
|
||||||
|
|
||||||
# -SystemProjects System \
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue