4 Copyright (C) 1996 Free Software Foundation, Inc.
6 Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
9 This file is part of the GNUstep Database Library.
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.
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.
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.
27 #include "EOSQLExpression.h"
28 #include "EOAttribute.h"
29 #include "EOAdaptor.h"
32 #if LIB_FOUNDATION_LIBRARY
33 # include <extensions/DefaultScannerHandler.h>
34 # include <extensions/PrintfFormatScanner.h>
36 # include "DefaultScannerHandler.h"
37 # include "PrintfFormatScanner.h"
40 @interface EOSelectScannerHandler : DefaultScannerHandler
42 EOAttribute *attribute;
47 - (void)setAttribute:(EOAttribute*)attribute
48 adaptor:(EOAdaptor*)adaptor
49 alias:(NSString*)alias;
53 @implementation EOSelectSQLExpression
55 - (NSString *)expressionValueForAttribute:(EOAttribute *)attribute
61 alias = [entitiesAndPropertiesAliases objectForKey:context];
63 //NSLog(@"entitiesAndPropertiesAliases: %@", entitiesAndPropertiesAliases);
66 ? [adaptor formatAttribute:attribute]
67 : [attribute columnName];
70 return [([[NSString alloc] initWithFormat:@"%@.%@",
71 alias, columnName]) autorelease];
77 @end /* EOSelectSQLExpression */
79 @implementation EOSelectScannerHandler
82 if ((self = [super init]) != nil) {
84 = [self methodForSelector:@selector(convertAttribute:scanner:)];
90 [self->attribute release];
91 [self->adaptor release];
92 [self->alias release];
96 - (void)setAttribute:(EOAttribute*)_attribute
97 adaptor:(EOAdaptor*)_adaptor
98 alias:(NSString*)_alias
100 ASSIGN(self->attribute, _attribute);
101 ASSIGN(self->adaptor, _adaptor);
102 ASSIGN(self->alias, _alias);
105 - (NSString *)convertAttribute:(va_list *)pString
106 scanner:(FormatScanner *)scanner
108 NSString *columnName;
110 columnName = (adaptor)
111 ? [adaptor formatAttribute:self->attribute]
112 : [self->attribute columnName];
115 return [NSString stringWithFormat:@"%@.%@", alias, columnName];
120 @end /* EOSelectScannerHandler */