]> err.no Git - sope/blob - sope-gdl1/GDLAccess/EOAndQualifier+SQL.m
fixed build with gstep-make 1.9.2
[sope] / sope-gdl1 / GDLAccess / EOAndQualifier+SQL.m
1 /* 
2    EOAttributeOrdering.m
3
4    Copyright (C) 1996 Free Software Foundation, Inc.
5
6    Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
7    Date: 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
27 // $Id: EOAndQualifier+SQL.m 1 2004-08-20 10:38:46Z znek $
28
29 #import "EOSQLQualifier.h"
30 #include "common.h"
31
32 @implementation EOAndQualifier(SQLQualifier)
33
34 /* SQL qualifier generation */
35
36 - (EOSQLQualifier *)sqlQualifierForEntity:(EOEntity *)_entity {
37   unsigned cc = [self->qualifiers count];
38
39   if (cc == 0) {
40     return nil;
41   }
42   else if (cc == 1) {
43     return [[self->qualifiers objectAtIndex:0] sqlQualifierForEntity:_entity];
44   }
45   else if (cc == 2) {
46     id left;
47     id right;
48
49     left  = [[self->qualifiers objectAtIndex:0] sqlQualifierForEntity:_entity];
50     right = [[self->qualifiers objectAtIndex:1] sqlQualifierForEntity:_entity];
51     [left conjoinWithQualifier:right];
52     return left;
53   }
54   else {
55     EOSQLQualifier *masterQ;
56     unsigned i;
57
58     for (i = 0, masterQ = nil; i < cc; i++) {
59       EOSQLQualifier *q;
60
61       q = [[self->qualifiers objectAtIndex:i]
62                              sqlQualifierForEntity:_entity];
63       if (masterQ == nil)
64         masterQ = q;
65       else
66         [masterQ conjoinWithQualifier:q];
67     }
68     return masterQ;
69   }
70 }
71
72 @end /* EOAndQualifier */