]> err.no Git - sope/blob - sope-gdl1/PostgreSQL/PostgreSQL72Expression.m
renamed PostgreSQL72 to PostgreSQL, install in Library/GDLAdaptors-1.1
[sope] / sope-gdl1 / PostgreSQL / PostgreSQL72Expression.m
1 /* 
2    PostgreSQL72Expression.m
3
4    Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
5
6    Author: Helge Hess (helge@mdlink.de)
7
8    This file is part of the PostgreSQL72 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: PostgreSQL72Expression.m 1 2004-08-20 10:38:46Z znek $
26
27 #include "PostgreSQL72Expression.h"
28 #include "common.h"
29
30 @implementation PostgreSQL72Expression
31
32 + (Class)selectExpressionClass  {
33   return [PostgreSQL72SelectSQLExpression class];
34 }
35
36 @end /* PostgreSQL72Expression */
37
38 @implementation PostgreSQL72SelectSQLExpression
39
40 - (id)selectExpressionForAttributes:(NSArray *)attributes
41   lock:(BOOL)flag
42   qualifier:(EOSQLQualifier *)qualifier
43   fetchOrder:(NSArray *)fetchOrder
44   channel:(EOAdaptorChannel *)channel {
45
46   lock = flag;
47   [super selectExpressionForAttributes:attributes
48          lock:flag
49          qualifier:qualifier
50          fetchOrder:fetchOrder
51          channel:channel];
52   return self;
53 }
54
55 - (NSString *)fromClause {
56   NSMutableString *fromClause;
57   NSEnumerator    *enumerator;
58   BOOL            first       = YES;
59   id              key;
60
61   fromClause = [NSMutableString stringWithCString:" "];
62   enumerator = [fromListEntities objectEnumerator];
63   
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.
68   
69   while((key = [enumerator nextObject])) {
70     if(first) first = NO;
71     else      [fromClause appendString:@", "];
72
73     [fromClause appendFormat:@"%@ %@",
74                   [key isKindOfClass:[EORelationship class]]
75                   ? [[key destinationEntity] externalName] // flattened attribute
76                   : [key externalName],                    // EOEntity
77                   [entitiesAndPropertiesAliases objectForKey:key]];
78
79 #if 0    
80     if (lock) [fromClause appendString:@" HOLDLOCK"];
81 #endif    
82   }
83
84   return fromClause;
85 }
86
87 @end
88
89 void __link_PostgreSQL72Expression() {
90   // used to force linking of object file
91   __link_PostgreSQL72Expression();
92 }