]> err.no Git - sope/blob - sope-gdl1/PostgreSQL/PostgreSQL72Expression.m
Add libxml2-dev to libsope-xml4.7-dev deps
[sope] / sope-gdl1 / PostgreSQL / PostgreSQL72Expression.m
1 /* 
2    PostgreSQL72Expression.m
3
4    Copyright (C) 1999      MDlink online service center GmbH and Helge Hess
5    Copyright (C) 2000-2006 SKYRIX Software AG and Helge Hess
6    
7    Author: Helge Hess (helge@opengroupware.org)
8
9    This file is part of the PostgreSQL Adaptor 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 #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 stringWithCapacity:64];
62   enumerator = [fromListEntities objectEnumerator];
63
64   [fromClause appendString:@" "];
65   
66   // Compute the FROM list from all the aliases found in
67   // entitiesAndPropertiesAliases dictionary. Note that this dictionary
68   // contains entities and relationships. The last ones are there for
69   // flattened attributes over reflexive relationships.
70   
71   while ((key = [enumerator nextObject]) != nil) {
72     if(first) first = NO;
73     else      [fromClause appendString:@", "];
74     
75     [fromClause appendString:
76                   [key isKindOfClass:[EORelationship class]]
77                   ? [[key destinationEntity] externalName]
78                     // flattened attribute
79                   : [key externalName]];
80                     // EOEntity
81     
82     [fromClause appendString:@" "];
83     [fromClause appendString:
84                 [[entitiesAndPropertiesAliases objectForKey:key] stringValue]];
85
86 #if 0    
87     if (lock) [fromClause appendString:@" HOLDLOCK"];
88 #endif    
89   }
90
91   return fromClause;
92 }
93
94 @end
95
96 void __link_PostgreSQL72Expression() {
97   // used to force linking of object file
98   __link_PostgreSQL72Expression();
99 }