From 81cd8b8581e1af8bb63f2be9786737671e54c052 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Tue, 27 Sep 2011 00:21:35 +0000 Subject: QueryKit updates. --- Frameworks/QueryKit/QKQuery.m | 3 +++ Frameworks/QueryKit/QKQueryParameter.m | 4 ++-- UnitTests/QKSelectQueryTests.m | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Frameworks/QueryKit/QKQuery.m b/Frameworks/QueryKit/QKQuery.m index cda3b877..31755b6d 100644 --- a/Frameworks/QueryKit/QKQuery.m +++ b/Frameworks/QueryKit/QKQuery.m @@ -412,6 +412,9 @@ static NSString *QKNoQueryTableException = @"QKNoQueryTable"; #pragma mark - +/** + * Same as calling -query. + */ - (NSString *)description { return [self query]; diff --git a/Frameworks/QueryKit/QKQueryParameter.m b/Frameworks/QueryKit/QKQueryParameter.m index d131c156..bc9efa2f 100644 --- a/Frameworks/QueryKit/QKQueryParameter.m +++ b/Frameworks/QueryKit/QKQueryParameter.m @@ -63,12 +63,12 @@ - (NSString *)description { NSMutableString *string = [NSMutableString string]; - + NSString *field = [_field stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; [string appendString:field]; [string appendFormat:@" %@ ", [QKQueryUtilities operatorRepresentationForType:_operator]]; - [string appendString:[_value description]]; + [string appendFormat:(![_value isKindOfClass:[NSNumber class]]) ? @"'%@'" : @"%@", [_value description]]; return string; } diff --git a/UnitTests/QKSelectQueryTests.m b/UnitTests/QKSelectQueryTests.m index 5d013987..84b4584c 100644 --- a/UnitTests/QKSelectQueryTests.m +++ b/UnitTests/QKSelectQueryTests.m @@ -32,7 +32,7 @@ static NSString *QKTestFieldTwo = @"test_field2"; static NSString *QKTestFieldThree = @"test_field3"; static NSString *QKTestFieldFour = @"test_field4"; -static NSString *QKTestParameterOne = @"10"; +static NSUInteger QKTestParameterOne = 10; @implementation QKSelectQueryTests @@ -48,7 +48,7 @@ static NSString *QKTestParameterOne = @"10"; [_query addField:QKTestFieldThree]; [_query addField:QKTestFieldFour]; - [_query addParameter:QKTestFieldOne operator:QKEqualityOperator value:QKTestParameterOne]; + [_query addParameter:QKTestFieldOne operator:QKEqualityOperator value:[NSNumber numberWithUnsignedInteger:QKTestParameterOne]]; } #pragma mark - @@ -68,7 +68,7 @@ static NSString *QKTestParameterOne = @"10"; - (void)testSelectQueryConstraintsAreCorrect { - NSString *query = [NSString stringWithFormat:@"WHERE %@ %@ %@", QKTestFieldOne, [QKQueryUtilities operatorRepresentationForType:QKEqualityOperator], QKTestParameterOne]; + NSString *query = [NSString stringWithFormat:@"WHERE %@ %@ %@", QKTestFieldOne, [QKQueryUtilities operatorRepresentationForType:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]]; STAssertTrue(([[_query query] rangeOfString:query].location != NSNotFound), @"query constraints"); } -- cgit v1.2.3