~ubuntu-branches/ubuntu/edgy/sope/edgy

« back to all changes in this revision

Viewing changes to sope-gdl1/GDLAccess/EOSQLExpression.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Ley
  • Date: 2005-08-19 16:53:31 UTC
  • Revision ID: james.westby@ubuntu.com-20050819165331-hs683wz1osm708pw
Tags: upstream-4.4rc.2
ImportĀ upstreamĀ versionĀ 4.4rc.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
   EOSQLExpression.h
 
3
 
 
4
   Copyright (C) 1996 Free Software Foundation, Inc.
 
5
 
 
6
   Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
 
7
   Date: September 1996
 
8
 
 
9
   This file is part of the GNUstep Database Library.
 
10
 
 
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.
 
15
 
 
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.
 
20
 
 
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.
 
25
*/
 
26
 
 
27
#ifndef __EOSQLExpression_h__
 
28
#define __EOSQLExpression_h__
 
29
 
 
30
#import <Foundation/NSDictionary.h>
 
31
#import <Foundation/NSArray.h>
 
32
 
 
33
#import <GDLAccess/EOExpressionArray.h>
 
34
#import <GDLAccess/EOJoinTypes.h>
 
35
 
 
36
@class EOAdaptor;
 
37
@class EOAdaptorChannel;
 
38
@class EOEntity;
 
39
@class EOSQLQualifier;
 
40
 
 
41
extern NSString *EOBindVariableNameKey;
 
42
extern NSString *EOBindVariablePlaceHolderKey;
 
43
extern NSString *EOBindVariableAttributeKey;
 
44
extern NSString *EOBindVariableValueKey;
 
45
 
 
46
@interface EOSQLExpression : NSObject <EOExpressionContext>
 
47
{
 
48
    EOEntity            *entity;
 
49
    EOAdaptor           *adaptor;
 
50
    NSMutableDictionary *entitiesAndPropertiesAliases;
 
51
    NSMutableArray      *fromListEntities;
 
52
    NSMutableString     *content;
 
53
 
 
54
    /* new in EOF2 */
 
55
    NSString            *whereClauseString;
 
56
    NSMutableString     *listString;
 
57
    NSMutableArray      *bindings;
 
58
}
 
59
 
 
60
/* Building SQL expressions */
 
61
 
 
62
+ (id)deleteExpressionWithQualifier:(EOSQLQualifier *)qualifier
 
63
  channel:(EOAdaptorChannel *)channel;
 
64
+ (id)insertExpressionForRow:(NSDictionary *)row
 
65
  entity:(EOEntity *)entity
 
66
  channel:(EOAdaptorChannel *)channel;
 
67
+ (id)selectExpressionForAttributes:(NSArray *)attributes
 
68
  lock:(BOOL)flag
 
69
  qualifier:(EOSQLQualifier *)qualifier
 
70
  fetchOrder:(NSArray *)fetchOrder
 
71
  channel:(EOAdaptorChannel *)channel;
 
72
+ (id)updateExpressionForRow:(NSDictionary *)row
 
73
  qualifier:(EOSQLQualifier *)qualifier
 
74
  channel:(EOAdaptorChannel *)channel;
 
75
 
 
76
- (id)deleteExpressionWithQualifier:(EOSQLQualifier *)qualifier
 
77
  channel:(EOAdaptorChannel *)channel;
 
78
- (id)insertExpressionForRow:(NSDictionary *)row
 
79
  entity:(EOEntity *)entity
 
80
  channel:(EOAdaptorChannel *)channel;
 
81
- (id)selectExpressionForAttributes:(NSArray *)attributes
 
82
  lock:(BOOL)flag
 
83
  qualifier:(EOSQLQualifier *)qualifier
 
84
  fetchOrder:(NSArray *)fetchOrder
 
85
  channel:(EOAdaptorChannel *)channel;
 
86
- (id)updateExpressionForRow:(NSDictionary *)row
 
87
  qualifier:(EOSQLQualifier *)qualifier
 
88
  channel:(EOAdaptorChannel *)channel;
 
89
 
 
90
/* factory classes */
 
91
 
 
92
+ (Class)selectExpressionClass;
 
93
+ (Class)insertExpressionClass;
 
94
+ (Class)deleteExpressionClass;
 
95
+ (Class)updateExpressionClass;
 
96
 
 
97
/* Getting the adaptor */
 
98
- (EOAdaptor *)adaptor;
 
99
 
 
100
// Private methods.
 
101
 
 
102
/* Creating components for the SELECT operation */
 
103
- (NSString *)selectListWithAttributes:(NSArray *)attributes
 
104
  qualifier:(EOSQLQualifier *)qualifier;
 
105
- (NSString *)fromClause;
 
106
- (NSString *)whereClauseForQualifier:(EOSQLQualifier *)qualifier;
 
107
- (NSString *)joinExpressionForRelationshipPaths:(NSArray *)relationshipPaths;
 
108
- (NSString *)lockClause;
 
109
- (NSString *)orderByClauseForFetchOrder:(NSArray *)fetchOrder;
 
110
 
 
111
/* Creating components for the UPDATE operation */
 
112
- (id)updateListForRow:(NSDictionary *)row;
 
113
 
 
114
/* Creating components for the INSERT operation */
 
115
- (id)columnListForRow:(NSDictionary *)row;
 
116
- (id)valueListForRow:(NSDictionary *)row;
 
117
 
 
118
/* Final initialization */
 
119
- (id)finishBuildingExpression;
 
120
 
 
121
/* Caching aliases */
 
122
- (NSArray *)relationshipPathsForAttributes:(NSArray *)attributes
 
123
  qualifier:(EOSQLQualifier *)qualifier
 
124
  fetchOrder:(NSArray *)fetchOrder;
 
125
 
 
126
/* Getting the entity */
 
127
- (EOEntity *)entity;
 
128
 
 
129
/* Getting the expression value of an attribute in a given context. This
 
130
   method is used by the expressionValueForAttribute: method. */
 
131
- (NSString *)expressionValueForAttribute:(EOAttribute *)attribute
 
132
  context:context;
 
133
 
 
134
@end
 
135
 
 
136
@class NSArray;
 
137
@class EOFetchSpecification, EOKeyComparisonQualifier, EOKeyValueQualifier;
 
138
@class EOQualifier;
 
139
 
 
140
@interface EOSQLExpression(NewInEOF2)
 
141
 
 
142
+ (EOSQLExpression *)selectStatementForAttributes:(NSArray *)_attributes
 
143
  lock:(BOOL)_flag
 
144
  fetchSpecification:(EOFetchSpecification *)_fspec
 
145
  entity:(EOEntity *)_entity;
 
146
+ (EOSQLExpression *)expressionForString:(NSString *)_sql;
 
147
 
 
148
/* accessors */
 
149
 
 
150
- (void)setStatement:(NSString *)_stmt;
 
151
- (NSString *)statement;
 
152
- (NSString *)whereClauseString;
 
153
 
 
154
/* tables */
 
155
 
 
156
- (NSString *)tableListWithRootEntity:(EOEntity *)_entity;
 
157
 
 
158
/* assembly */
 
159
 
 
160
- (NSString *)assembleDeleteStatementWithQualifier:(EOQualifier *)_qualifier
 
161
  tableList:(NSString *)_tableList
 
162
  whereClause:(NSString *)_whereClause;
 
163
 
 
164
- (NSString *)assembleInsertStatementWithRow:(NSDictionary *)_row
 
165
  tableList:(NSString *)_tables
 
166
  columnList:(NSString *)_columns
 
167
  valueList:(NSString *)_values;
 
168
 
 
169
- (NSString *)assembleSelectStatementWithAttributes:(NSArray *)_attributes
 
170
  lock:(BOOL)_lock
 
171
  qualifier:(EOQualifier *)_qualifier
 
172
  fetchOrder:(NSArray *)_fetchOrder
 
173
  selectString:(NSString *)_selectString
 
174
  columnList:(NSString *)_columns
 
175
  tableList:(NSString *)_tables
 
176
  whereClause:(NSString *)_whereClause
 
177
  joinClause:(NSString *)_joinClause
 
178
  orderByClause:(NSString *)_orderByClause
 
179
  lockClause:(NSString *)_lockClause;
 
180
 
 
181
- (NSString *)assembleUpdateStatementWithRow:(NSDictionary *)_row
 
182
  qualifier:(EOQualifier *)_qualifier
 
183
  tableList:(NSString *)_tables
 
184
  updateList:(NSString *)_updates
 
185
  whereClause:(NSString *)_whereClause;
 
186
 
 
187
- (NSString *)assembleJoinClauseWithLeftName:(NSString *)_leftName
 
188
  rightName:(NSString *)_rightName
 
189
  joinSemantic:(EOJoinSemantic)_semantic;
 
190
 
 
191
/* bind variables */
 
192
 
 
193
- (BOOL)mustUseBindVariableForAttribute:(EOAttribute *)_attr;
 
194
- (BOOL)shouldUseBindVariableForAttribute:(EOAttribute *)_attr;
 
195
+ (BOOL)useBindVariables;
 
196
- (NSMutableDictionary *)bindVariableDictionaryForAttribute:(EOAttribute *)_attr
 
197
  value:(id)_value;
 
198
- (void)addBindVariableDictionary:(NSMutableDictionary *)_dictionary;
 
199
- (NSArray *)bindVariableDictionaries;
 
200
 
 
201
/* values */
 
202
 
 
203
+ (NSString *)formatValue:(id)_value forAttribute:(EOAttribute *)_attribute;
 
204
- (NSString *)sqlStringForValue:(id)_value attributeNamed:(NSString *)_attrName;
 
205
+ (NSString *)sqlPatternFromShellPattern:(NSString *)_pattern;
 
206
 
 
207
/* attributes */
 
208
 
 
209
- (NSString *)sqlStringForAttribute:(EOAttribute *)_attribute;
 
210
- (NSString *)sqlStringForAttributePath:(NSString *)_attrPath;
 
211
- (NSString *)sqlStringForAttributeNamed:(NSString *)_attrName;
 
212
 
 
213
/* SQL formats */
 
214
 
 
215
+ (NSString *)formatSQLString:(NSString *)_sqlString format:(NSString *)_fmt;
 
216
 
 
217
/* qualifier operators */
 
218
 
 
219
- (NSString *)sqlStringForSelector:(SEL)_selector value:(id)_value;
 
220
 
 
221
/* qualifiers */
 
222
 
 
223
- (NSString *)sqlStringForKeyComparisonQualifier:(EOKeyComparisonQualifier *)_q;
 
224
- (NSString *)sqlStringForKeyValueQualifier:(EOKeyValueQualifier *)_q;
 
225
- (NSString *)sqlStringForNegatedQualifier:(EOQualifier *)_q;
 
226
- (NSString *)sqlStringForConjoinedQualifiers:(NSArray *)_qs;
 
227
- (NSString *)sqlStringForDisjoinedQualifiers:(NSArray *)_qs;
 
228
 
 
229
/* list strings */
 
230
 
 
231
- (NSMutableString *)listString;
 
232
- (void)appendItem:(NSString *)_itemString toListString:(NSMutableString *)_lstr;
 
233
 
 
234
/* deletes */
 
235
 
 
236
- (void)prepareDeleteExpressionForQualifier:(EOQualifier *)_qualifier;
 
237
 
 
238
/* updates */
 
239
 
 
240
- (void)addUpdateListAttribute:(EOAttribute *)_attr value:(NSString *)_value;
 
241
 
 
242
- (void)prepareUpdateExpressionWithRow:(NSDictionary *)_row
 
243
  qualifier:(EOQualifier *)_qualifier;
 
244
 
 
245
@end
 
246
 
 
247
/* Private subclasses used by EOSQLExpression. */
 
248
 
 
249
@interface EOSelectSQLExpression : EOSQLExpression
 
250
@end
 
251
 
 
252
@interface EOUpdateSQLExpression : EOSQLExpression
 
253
@end
 
254
 
 
255
@interface EOInsertSQLExpression : EOSQLExpression
 
256
@end
 
257
 
 
258
@interface EODeleteSQLExpression : EOSQLExpression
 
259
@end
 
260
 
 
261
#endif /* __EOSQLExpression_h__ */
 
262
 
 
263
/*
 
264
  Local Variables:
 
265
  c-basic-offset: 4
 
266
  tab-width: 8
 
267
  End:
 
268
*/