]> err.no Git - sope/blob - sope-gdl1/SQLite3/SQLiteAdaptor.m
fixed gdltest
[sope] / sope-gdl1 / SQLite3 / SQLiteAdaptor.m
1 /* 
2    SQLiteAdaptor.m
3
4    Copyright (C) 2003 SKYRIX Software AG
5
6    Author: Helge Hess (helge.hess@skyrix.com)
7
8    This file is part of the SQLite Adaptor Library
9
10    This library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Library General Public
12    License as published by the Free Software Foundation; either
13    version 2 of the License, or (at your option) any later version.
14
15    This library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    Library General Public License for more details.
19
20    You should have received a copy of the GNU Library General Public
21    License along with this library; see the file COPYING.LIB.
22    If not, write to the Free Software Foundation,
23    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */
25 // $Id: SQLiteAdaptor.m,v 1.1 2004/06/14 14:27:44 helge Exp $
26
27 #import "common.h"
28 #import "SQLiteAdaptor.h"
29 #import "SQLiteContext.h"
30 #import "SQLiteChannel.h"
31 #import "SQLiteExpression.h"
32 #import "SQLiteValues.h"
33
34 @implementation SQLiteAdaptor
35
36 - (id)initWithName:(NSString *)_name {
37   if ((self = [super initWithName:_name])) {
38   }
39   return self;
40 }
41
42 /* NSCopying methods */
43
44 - (id)copyWithZone:(NSZone *)_zone {
45   return [self retain];
46 }
47
48 // connections
49
50 - (NSString *)serverName {
51   return @"localhost";
52 }
53 - (NSString *)loginName {
54   return @"no-login-required";
55 }
56 - (NSString *)loginPassword {
57   return @"no-pwd-required";
58 }
59 - (NSString *)databaseName {
60   return [[[[self connectionDictionary]
61                   objectForKey:@"databaseName"] copy] autorelease];
62 }
63
64 - (NSString *)port {
65   return @"no-port-required";
66 }
67 - (NSString *)options {
68   return [[[[self connectionDictionary]
69                   objectForKey:@"options"] copy] autorelease];
70 }
71
72 /* sequence for primary key generation */
73
74 - (NSString *)primaryKeySequenceName {
75   NSString *seqName;
76
77   seqName =
78     [[self pkeyGeneratorDictionary] objectForKey:@"primaryKeySequenceName"];
79   return [[seqName copy] autorelease];
80 }
81
82 - (NSString *)newKeyExpression {
83   NSString *newKeyExpr;
84   
85   newKeyExpr =
86     [[self pkeyGeneratorDictionary] objectForKey:@"newKeyExpression"];
87   return [[newKeyExpr copy] autorelease];
88 }
89
90 // formatting
91
92 - (NSString *)charConvertExpressionForAttributeNamed:(NSString *)_attrName {
93   return _attrName;
94 }
95
96 - (id)formatValue:(id)value forAttribute:(EOAttribute *)attribute {
97   NSString *result;
98   
99   result = [value stringValueForSQLite3Type:[attribute externalType]
100                   attribute:attribute];
101
102   //NSLog(@"formatting value %@ result %@", value, result);
103   //NSLog(@"  value class %@ attr %@ attr type %@",
104   //             [value class], attribute, [attribute externalType]);
105
106   return result;
107 }
108
109 - (BOOL)attributeAllowedInDistinctSelects:(EOAttribute *)_attr {
110   return YES;
111 }
112
113 /* types */
114
115 - (BOOL)isValidQualifierType:(NSString *)_typeName {
116   return YES;
117 }
118
119 /* adaptor info */
120
121 - (Class)adaptorContextClass {
122   return [SQLiteContext class];
123 }
124 - (Class)adaptorChannelClass {
125   return [SQLiteChannel class];
126 }
127
128 - (Class)expressionClass {
129   return [SQLiteExpression class];
130 }
131
132 @end /* SQLiteAdaptor */
133
134 void __linkSQLiteAdaptor(void) {
135   extern void __link_EOAttributeSQLite();
136   extern void __link_NSStringSQLite();
137   extern void __link_SQLiteChannelModel();
138   extern void __link_SQLiteValues();
139   ;
140   [SQLiteChannel    class];
141   [SQLiteContext    class];
142   [SQLiteException  class];
143   [SQLiteExpression class];
144   __link_EOAttributeSQLite();
145   __link_NSStringSQLite();
146   //__link_SQLiteChannelModel();
147   __link_SQLiteValues();
148   __linkSQLiteAdaptor();
149 }