]> err.no Git - sope/blob - sope-gdl1/GDLAccess/EOKeyComparisonQualifier+SQL.m
renamed PostgreSQL72 to PostgreSQL, install in Library/GDLAdaptors-1.1
[sope] / sope-gdl1 / GDLAccess / EOKeyComparisonQualifier+SQL.m
1 /* 
2    EOAdaptorChannel.m
3
4    Copyright (C) 1996 Free Software Foundation, Inc.
5
6    Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
7    Date: October 1996
8
9    This file is part of the GNUstep Database 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 // $Id: EOKeyComparisonQualifier+SQL.m 1 2004-08-20 10:38:46Z znek $
27
28 #import "EOSQLQualifier.h"
29 #include "common.h"
30
31 #if NeXT_RUNTIME || APPLE_RUNTIME
32 #  ifndef SEL_EQ
33 #    define SEL_EQ(__A__,__B__) (__A__==__B__?YES:NO)
34 #  endif
35 #endif
36
37 @implementation EOKeyComparisonQualifier(SQLQualifier)
38
39 /* SQL qualifier generation */
40
41 - (EOSQLQualifier *)sqlQualifierForEntity:(EOEntity *)_entity {
42   EOSQLQualifier *q;
43   NSString *format;
44
45   if (SEL_EQ(self->operator, EOQualifierOperatorEqual))
46       format = @"%A = %A";
47   else if (SEL_EQ(self->operator, EOQualifierOperatorNotEqual))
48       format = @"%A <> %A";
49   else if (SEL_EQ(self->operator, EOQualifierOperatorLessThan))
50       format = @"%A < %A";
51   else if (SEL_EQ(self->operator, EOQualifierOperatorGreaterThan))
52       format = @"%A > %A";
53   else if (SEL_EQ(self->operator, EOQualifierOperatorLessThanOrEqualTo))
54       format = @"%A <= %A";
55   else if (SEL_EQ(self->operator, EOQualifierOperatorGreaterThanOrEqualTo))
56       format = @"%A >= %A";
57   else if (SEL_EQ(self->operator, EOQualifierOperatorLike))
58       format = @"%A LIKE %A";
59   else {
60       format = [NSString stringWithFormat:@"%%A %@ %%A",
61                            NSStringFromSelector(self->operator)];
62   }
63   
64   q = [[EOSQLQualifier alloc]
65                        initWithEntity:_entity
66                        qualifierFormat:format, self->leftKey, self->rightKey];
67   return AUTORELEASE(q);
68 }
69
70 @end /* EOKeyComparisonQualifier(SQLQualifier) */