4 Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
5 Copyright (C) 2000-2004 SKYRIX Software AG and Helge Hess
7 Author: Helge Hess (helge.hess@opengroupware.org)
9 This file is part of the PostgreSQL72 Adaptor Library
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Library General Public License for more details.
21 You should have received a copy of the GNU Library General Public
22 License along with this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 // $Id: PostgreSQL72Adaptor.m 1 2004-08-20 10:38:46Z znek $
29 #include "PostgreSQL72Adaptor.h"
30 #include "PostgreSQL72Context.h"
31 #include "PostgreSQL72Channel.h"
32 #include "PostgreSQL72Expression.h"
33 #include "PostgreSQL72Values.h"
34 #include "PGConnection.h"
36 @implementation PostgreSQL72Adaptor
38 static BOOL debugOn = NO;
40 - (id)initWithName:(NSString *)_name {
41 if ((self = [super initWithName:_name])) {
50 // NSLog(@"%s", __PRETTY_FUNCTION__);
55 /* NSCopying methods */
57 - (id)copyWithZone:(NSZone *)_zone {
63 - (NSString *)_copyOfConDictString:(NSString *)_key {
64 return [[[[self connectionDictionary] objectForKey:_key] copy] autorelease];
67 - (NSString *)serverName {
70 serverName = [[self connectionDictionary] objectForKey:@"hostName"];
72 if (serverName == nil) { // lookup env-variable
74 [[[NSProcessInfo processInfo] environment] objectForKey:@"PGHOST"];
77 return [[serverName copy] autorelease];
79 - (NSString *)loginName {
80 return [self _copyOfConDictString:@"userName"];
82 - (NSString *)loginPassword {
83 return [self _copyOfConDictString:@"password"];
85 - (NSString *)databaseName {
86 return [self _copyOfConDictString:@"databaseName"];
90 return [self _copyOfConDictString:@"port"];
92 - (NSString *)options {
93 return [self _copyOfConDictString:@"options"];
96 return [self _copyOfConDictString:@"tty"];
99 /* sequence for primary key generation */
101 - (NSString *)primaryKeySequenceName {
105 [[self pkeyGeneratorDictionary] objectForKey:@"primaryKeySequenceName"];
106 return [[seqName copy] autorelease];
109 - (NSString *)newKeyExpression {
110 NSString *newKeyExpr;
113 [[self pkeyGeneratorDictionary] objectForKey:@"newKeyExpression"];
114 return [[newKeyExpr copy] autorelease];
119 - (NSString *)charConvertExpressionForAttributeNamed:(NSString *)_attrName {
123 - (id)formatValue:(id)value forAttribute:(EOAttribute *)attribute {
125 This formats values into SQL constants, eg:
126 @"blah" will be converted to 'blah'
130 result = [value stringValueForPostgreSQLType:[attribute externalType]
131 attribute:attribute];
133 NSLog(@"formatting value '%@'(%@) result '%@'",
134 value, NSStringFromClass([value class]), result);
135 NSLog(@" value class %@ attr %@ attr type %@",
136 [value class], attribute, [attribute externalType]);
141 - (BOOL)attributeAllowedInDistinctSelects:(EOAttribute *)_attr {
147 - (BOOL)isValidQualifierType:(NSString *)_typeName {
153 - (Class)adaptorContextClass {
154 return [PostgreSQL72Context class];
156 - (Class)adaptorChannelClass {
157 return [PostgreSQL72Channel class];
160 - (Class)expressionClass {
161 return [PostgreSQL72Expression class];
164 @end /* PostgreSQL72Adaptor */
166 void __linkPostgreSQL72Adaptor(void) {
167 extern void __link_EOAttributePostgreSQL72();
168 extern void __link_NSStringPostgreSQL72();
169 extern void __link_PostgreSQL72ChannelModel();
170 extern void __link_PostgreSQL72Values();
172 [PostgreSQL72Channel class];
173 [PostgreSQL72Context class];
174 [PostgreSQL72Exception class];
175 [PostgreSQL72Expression class];
176 __link_EOAttributePostgreSQL72();
177 __link_NSStringPostgreSQL72();
178 //__link_PostgreSQL72ChannelModel();
179 __link_PostgreSQL72Values();
180 __linkPostgreSQL72Adaptor();