4
Copyright (C) 2003-2005 SKYRIX Software AG
6
Author: Helge Hess (helge.hess@skyrix.com)
8
This file is part of the SQLite Adaptor Library
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.
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.
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.
26
#include "SQLiteAdaptor.h"
27
#include "SQLiteContext.h"
28
#include "SQLiteChannel.h"
29
#include "SQLiteExpression.h"
30
#include "SQLiteValues.h"
33
@implementation SQLiteAdaptor
35
- (NSDictionary *)connectionDictionaryForNSURL:(NSURL *)_url {
40
SQLite3://localhost/dbpath/foldername
42
NSMutableDictionary *md;
45
if ((p = [_url path]) == nil)
48
p = [p stringByDeletingLastPathComponent];
49
if ([p length] == 0) p = [_url path];
51
md = [NSMutableDictionary dictionaryWithCapacity:8];
52
[md setObject:p forKey:@"databaseName"];
56
- (id)initWithName:(NSString *)_name {
57
if ((self = [super initWithName:_name])) {
62
/* NSCopying methods */
64
- (id)copyWithZone:(NSZone *)_zone {
70
- (NSString *)serverName {
73
- (NSString *)loginName {
74
return @"no-login-required";
76
- (NSString *)loginPassword {
77
return @"no-pwd-required";
79
- (NSString *)databaseName {
80
return [[[[self connectionDictionary]
81
objectForKey:@"databaseName"] copy] autorelease];
85
return @"no-port-required";
87
- (NSString *)options {
88
return [[[[self connectionDictionary]
89
objectForKey:@"options"] copy] autorelease];
92
/* sequence for primary key generation */
94
- (NSString *)primaryKeySequenceName {
98
[[self pkeyGeneratorDictionary] objectForKey:@"primaryKeySequenceName"];
99
return [[seqName copy] autorelease];
102
- (NSString *)newKeyExpression {
103
NSString *newKeyExpr;
106
[[self pkeyGeneratorDictionary] objectForKey:@"newKeyExpression"];
107
return [[newKeyExpr copy] autorelease];
112
- (NSString *)charConvertExpressionForAttributeNamed:(NSString *)_attrName {
116
- (id)formatValue:(id)value forAttribute:(EOAttribute *)attribute {
119
result = [value stringValueForSQLite3Type:[attribute externalType]
120
attribute:attribute];
122
//NSLog(@"formatting value %@ result %@", value, result);
123
//NSLog(@" value class %@ attr %@ attr type %@",
124
// [value class], attribute, [attribute externalType]);
129
- (BOOL)attributeAllowedInDistinctSelects:(EOAttribute *)_attr {
135
- (BOOL)isValidQualifierType:(NSString *)_typeName {
141
- (Class)adaptorContextClass {
142
return [SQLiteContext class];
144
- (Class)adaptorChannelClass {
145
return [SQLiteChannel class];
148
- (Class)expressionClass {
149
return [SQLiteExpression class];
152
@end /* SQLiteAdaptor */
154
void __linkSQLiteAdaptor(void) {
155
extern void __link_EOAttributeSQLite();
156
extern void __link_NSStringSQLite();
157
extern void __link_SQLiteChannelModel();
158
extern void __link_SQLiteValues();
160
[SQLiteChannel class];
161
[SQLiteContext class];
162
[SQLiteException class];
163
[SQLiteExpression class];
164
__link_EOAttributeSQLite();
165
__link_NSStringSQLite();
166
//__link_SQLiteChannelModel();
167
__link_SQLiteValues();
168
__linkSQLiteAdaptor();