From 12e46711ddc49b8791233a42dea72d34751aba54 Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 11 Apr 2005 18:52:23 +0000 Subject: [PATCH] more reorgs git-svn-id: http://svn.opengroupware.org/SOPE/trunk@724 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-gdl1/MySQL4/MySQL4Adaptor.m | 23 ++++++++++++++++++----- sope-gdl1/MySQL4/MySQL4Channel+Model.m | 22 +++++++++++----------- sope-gdl1/MySQL4/MySQL4Channel.m | 2 +- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/sope-gdl1/MySQL4/MySQL4Adaptor.m b/sope-gdl1/MySQL4/MySQL4Adaptor.m index bc2441ae..66dda5a0 100644 --- a/sope-gdl1/MySQL4/MySQL4Adaptor.m +++ b/sope-gdl1/MySQL4/MySQL4Adaptor.m @@ -44,16 +44,29 @@ return [self retain]; } -// connections +/* connections */ + +- (NSString *)_copyOfConDictString:(NSString *)_key { + return [[[[self connectionDictionary] objectForKey:_key] copy] autorelease]; +} - (NSString *)serverName { - return @"localhost"; + NSString *serverName; + + serverName = [[self connectionDictionary] objectForKey:@"hostName"]; + + if (serverName == nil) { // lookup env-variable + serverName = + [[[NSProcessInfo processInfo] environment] objectForKey:@"PGHOST"]; + } + + return [[serverName copy] autorelease]; } - (NSString *)loginName { - return @"no-login-required"; + return [self _copyOfConDictString:@"userName"]; } - (NSString *)loginPassword { - return @"no-pwd-required"; + return [self _copyOfConDictString:@"password"]; } - (NSString *)databaseName { return [[[[self connectionDictionary] @@ -61,7 +74,7 @@ } - (NSString *)port { - return @"no-port-required"; + return [self _copyOfConDictString:@"port"]; } - (NSString *)options { return [[[[self connectionDictionary] diff --git a/sope-gdl1/MySQL4/MySQL4Channel+Model.m b/sope-gdl1/MySQL4/MySQL4Channel+Model.m index 4272cfc9..06a6c2e7 100644 --- a/sope-gdl1/MySQL4/MySQL4Channel+Model.m +++ b/sope-gdl1/MySQL4/MySQL4Channel+Model.m @@ -71,7 +71,7 @@ NSString *attrName = nil; columnName = [[row objectForKey:@"attname"] stringValue]; - attrName = [columnName _sqlite3ModelMakeInstanceVarName]; + attrName = [columnName _mySQL4ModelMakeInstanceVarName]; externalType = [[row objectForKey:@"typname"] stringValue]; attribute = [[EOAttribute alloc] init]; @@ -123,9 +123,9 @@ int ac = [attributes count]; int fkc = [fkeys count]; - [entity setName:[tableName _sqlite3ModelMakeClassName]]; + [entity setName:[tableName _mySQL4ModelMakeClassName]]; [entity setClassName: - [@"EO" stringByAppendingString:[tableName _sqlite3ModelMakeClassName]]]; + [@"EO" stringByAppendingString:[tableName _mySQL4ModelMakeClassName]]]; [entity setExternalName:tableName]; [classProperties addObjectsFromArray:[entity classProperties]]; [primaryKeyAttributes addObjectsFromArray:[entity primaryKeyAttributes]]; @@ -159,12 +159,12 @@ if ([pkeys containsObject:sa]) { relName = [@"to" stringByAppendingString: - [dt _sqlite3ModelMakeClassName]]; + [dt _mySQL4ModelMakeClassName]]; } else { relName = [@"to" stringByAppendingString: - [[sa _sqlite3ModelMakeInstanceVarName] - _sqlite3StringWithCapitalizedFirstChar]]; + [[sa _mySQL4ModelMakeInstanceVarName] + _mySQL4StringWithCapitalizedFirstChar]]; if ([relName hasSuffix:@"Id"]) { int cLength = [relName cStringLength]; @@ -183,14 +183,14 @@ [relNamesUsed setObject:[NSNumber numberWithInt:0] forKey:relName]; [rel setName:relName]; - //[rel setDestinationEntity:(EOEntity *)[dt _sqlite3ModelMakeClassName]]; + //[rel setDestinationEntity:(EOEntity *)[dt _mySQL4ModelMakeClassName]]; [rel setToMany:NO]; // TODO: EOJoin is removed, fix this ... [(id)join setSourceAttribute: - (EOAttribute *)[sa _sqlite3ModelMakeInstanceVarName]]; + (EOAttribute *)[sa _mySQL4ModelMakeInstanceVarName]]; [(id)join setDestinationAttribute: - (EOAttribute *)[da _sqlite3ModelMakeInstanceVarName]]; + (EOAttribute *)[da _mySQL4ModelMakeInstanceVarName]]; [rel addJoin:join]; [entity addRelationship:rel]; @@ -226,8 +226,8 @@ [(EOEntity *)[reverse destinationEntity] name]]; else { relName = [@"to" stringByAppendingString: - [[[sa name] _sqlite3ModelMakeInstanceVarName] - _sqlite3StringWithCapitalizedFirstChar]]; + [[[sa name] _mySQL4ModelMakeInstanceVarName] + _mySQL4StringWithCapitalizedFirstChar]]; if ([relName hasSuffix:@"Id"]) { int cLength = [relName cStringLength]; diff --git a/sope-gdl1/MySQL4/MySQL4Channel.m b/sope-gdl1/MySQL4/MySQL4Channel.m index c4a7b340..c3d9df0b 100644 --- a/sope-gdl1/MySQL4/MySQL4Channel.m +++ b/sope-gdl1/MySQL4/MySQL4Channel.m @@ -503,6 +503,7 @@ static int openConnectionCount = 0; __PRETTY_FUNCTION__, cnt); continue; } +#endif if (value == nil) { NSLog(@"ERROR(%s): %@: got no value for column:\n" @@ -513,7 +514,6 @@ static int openConnectionCount = 0; continue; } } -#endif if (value != nil) { [row setObject:value forKey:attrName]; [value release]; -- 2.39.5