4 Copyright (C) 2003-2005 Helge Hess
6 Author: Helge Hess (helge.hess@opengroupware.org)
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 <Foundation/Foundation.h>
27 #include <GDLAccess/GDLAccess.h>
28 #include "SQLiteExpression.h"
30 @implementation SQLiteExpression
32 + (Class)selectExpressionClass {
33 return [SQLiteSelectSQLExpression class];
36 @end /* SQLiteExpression */
38 @implementation SQLiteSelectSQLExpression
40 - (id)selectExpressionForAttributes:(NSArray *)attributes
42 qualifier:(EOSQLQualifier *)qualifier
43 fetchOrder:(NSArray *)fetchOrder
44 channel:(EOAdaptorChannel *)channel {
47 [super selectExpressionForAttributes:attributes
55 - (NSString *)fromClause {
56 NSMutableString *fromClause;
57 NSEnumerator *enumerator;
61 fromClause = [NSMutableString stringWithCString:" "];
62 enumerator = [fromListEntities objectEnumerator];
64 // Compute the FROM list from all the aliases found in
65 // entitiesAndPropertiesAliases dictionary. Note that this dictionary
66 // contains entities and relationships. The last ones are there for
67 // flattened attributes over reflexive relationships.
69 while((key = [enumerator nextObject])) {
71 else [fromClause appendString:@", "];
73 [fromClause appendFormat:@"%@ %@",
74 [key isKindOfClass:[EORelationship class]]
75 ? [[key destinationEntity] externalName] // flattened attribute
76 : [key externalName], // EOEntity
77 [entitiesAndPropertiesAliases objectForKey:key]];
80 if (lock) [fromClause appendString:@" HOLDLOCK"];
87 @end /* SQLiteSelectSQLExpression */
89 void __link_SQLiteExpression() {
90 // used to force linking of object file
91 __link_SQLiteExpression();