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.
26 // $Id: EOQualifier+SQL.m 1 2004-08-20 10:38:46Z znek $
28 #include "EOSQLExpression.h"
29 #include "EOSQLQualifier.h"
30 #include <EOControl/EOQualifier.h>
33 @implementation EOAndQualifier(SQLGeneration)
35 - (NSString *)sqlStringForSQLExpression:(EOSQLExpression *)_sqlExpr {
36 return [_sqlExpr sqlStringForConjoinedQualifiers:[self qualifiers]];
39 - (EOQualifier *)schemaBasedQualifierWithRootEntity:(EOEntity *)_entity {
41 id objects[self->count + 1];
46 objAtIdx = [self->qualifiers methodForSelector:@selector(objectAtIndex:)];
48 for (i = 0; i < self->count; i++) {
51 q = objAtIdx(self->qualifiers, @selector(objectAtIndex:), i);
52 newq = [q schemaBasedQualifierWithRootEntity:_entity];
53 if (newq == nil) newq = q;
58 array = [NSArray arrayWithObjects:objects count:self->count];
59 return [[[[self class] alloc] initWithQualifierArray:array] autorelease];
62 @end /* EOAndQualifier(SQLGeneration) */
64 @implementation EOOrQualifier(SQLGeneration)
66 - (NSString *)sqlStringForSQLExpression:(EOSQLExpression *)_sqlExpr {
67 return [_sqlExpr sqlStringForDisjoinedQualifiers:[self qualifiers]];
70 - (EOQualifier *)schemaBasedQualifierWithRootEntity:(EOEntity *)_entity {
72 id objects[self->count + 1];
77 objAtIdx = [self->qualifiers methodForSelector:@selector(objectAtIndex:)];
79 for (i = 0; i < self->count; i++) {
82 q = objAtIdx(self->qualifiers, @selector(objectAtIndex:), i);
83 newq = [q schemaBasedQualifierWithRootEntity:_entity];
84 if (newq == nil) newq = q;
89 array = [NSArray arrayWithObjects:objects count:self->count];
90 return [[[[self class] alloc] initWithQualifierArray:array] autorelease];
93 @end /* EOOrQualifier(SQLGeneration) */
95 @implementation EONotQualifier(SQLGeneration)
97 - (NSString *)sqlStringForSQLExpression:(EOSQLExpression *)_sqlExpr {
98 return [_sqlExpr sqlStringForNegatedQualifier:[self qualifier]];
101 - (EOQualifier *)schemaBasedQualifierWithRootEntity:(EOEntity *)_entity {
104 sq = [(id<EOQualifierSQLGeneration>)self->qualifier
105 schemaBasedQualifierWithRootEntity:_entity];
106 if (sq == self->qualifier)
109 sq = [[EONotQualifier alloc] initWithQualifier:sq];
110 return [sq autorelease];
113 @end /* EONotQualifier(SQLGeneration) */
115 @implementation EOKeyValueQualifier(SQLGeneration)
117 - (NSString *)sqlStringForSQLExpression:(EOSQLExpression *)_sqlExpr {
118 return [_sqlExpr sqlStringForKeyValueQualifier:self];
121 - (EOQualifier *)schemaBasedQualifierWithRootEntity:(EOEntity *)_entity {
122 NSLog(@"ERROR(%s): subclasses need to override this method!",
123 __PRETTY_FUNCTION__);
127 @end /* EOKeyValueQualifier(SQLGeneration) */
129 @implementation EOKeyComparisonQualifier(SQLGeneration)
131 - (NSString *)sqlStringForSQLExpression:(EOSQLExpression *)_sqlExpr {
132 return [_sqlExpr sqlStringForKeyComparisonQualifier:self];
135 - (EOQualifier *)schemaBasedQualifierWithRootEntity:(EOEntity *)_entity {
136 NSLog(@"ERROR(%s): subclasses need to override this method!",
137 __PRETTY_FUNCTION__);
141 @end /* EOKeyComparisonQualifier(SQLGeneration) */