mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-02-21 02:41:07 +00:00
Support quoting of NSArray and NSSet objects
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@22542 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f4bf045efc
commit
e965604e5b
2 changed files with 18 additions and 11 deletions
|
@ -1,3 +1,7 @@
|
|||
2005-02-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* SQLClient.m: Support quoting of NSArray and NSSet objects.
|
||||
|
||||
2006-01-11 Nicola Pero <nicola@brainstorm.co.uk>
|
||||
|
||||
* configure.ac: Do not source GNUSTEP_CONFIG_FILE if it doesn't
|
||||
|
|
25
SQLClient.m
25
SQLClient.m
|
@ -62,6 +62,7 @@ static NSNull *null = nil;
|
|||
static Class NSStringClass = 0;
|
||||
static Class NSArrayClass = 0;
|
||||
static Class NSDateClass = 0;
|
||||
static Class NSSetClass = 0;
|
||||
|
||||
@implementation SQLRecord
|
||||
+ (id) allocWithZone: (NSZone*)aZone
|
||||
|
@ -440,6 +441,7 @@ static unsigned int maxConnections = 8;
|
|||
rollbackStatement = RETAIN([NSArray arrayWithObject: rollbackString]);
|
||||
NSStringClass = [NSString class];
|
||||
NSArrayClass = [NSArray class];
|
||||
NSSetClass = [NSSet class];
|
||||
[NSTimer scheduledTimerWithTimeInterval: 1.0
|
||||
target: self
|
||||
selector: @selector(_tick:)
|
||||
|
@ -918,24 +920,25 @@ static void quoteString(NSMutableString *s)
|
|||
}
|
||||
|
||||
/**
|
||||
* For an NSArray object, we produce a bracketed list of the
|
||||
* For an NSArray or NSSet, we produce a bracketed list of the
|
||||
* (quoted) objects in the array.
|
||||
*/
|
||||
if ([obj isKindOfClass: NSArrayClass] == YES)
|
||||
if ([obj isKindOfClass: NSArrayClass] == YES ||
|
||||
[obj isKindOfClass: NSSetClass] == YES)
|
||||
{
|
||||
NSMutableString *ms = [NSMutableString stringWithCapacity: 100];
|
||||
unsigned count = [obj count];
|
||||
unsigned i;
|
||||
NSEnumerator *enumerator = [obj objectEnumerator];
|
||||
id value = [enumerator nextObject];
|
||||
|
||||
[ms appendString: @"("];
|
||||
if (count > 0)
|
||||
if (value != nil)
|
||||
{
|
||||
[ms appendString: [self quote: [obj objectAtIndex: 0]]];
|
||||
for (i = 1; i < count; i++)
|
||||
{
|
||||
[ms appendString: @","];
|
||||
[ms appendString: [self quote: [obj objectAtIndex: i]]];
|
||||
}
|
||||
[ms appendString: [self quote: value]];
|
||||
}
|
||||
while ((value = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[ms appendString: @","];
|
||||
[ms appendString: [self quote: value]];
|
||||
}
|
||||
[ms appendString: @")"];
|
||||
return ms;
|
||||
|
|
Loading…
Reference in a new issue