From cb00d18102f8c3f88e8a15bb4d9fb7825cf29a59 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sun, 15 Jul 2012 10:15:11 +0000 Subject: Add a new order by class. --- .../QueryKit/Tests/QKSelectQueryOrderByTests.m | 28 +++++++++++++--------- Frameworks/QueryKit/Tests/QKUpdateQueryTests.m | 2 ++ 2 files changed, 19 insertions(+), 11 deletions(-) (limited to 'Frameworks/QueryKit/Tests') diff --git a/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m b/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m index 4ea01e4a..5f5c7356 100644 --- a/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m +++ b/Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m @@ -55,10 +55,10 @@ - (void)testSelectQueryOrderByAscendingIsCorrect { [_query orderByField:QKTestFieldOne descending:NO]; - + NSString *query = [NSString stringWithFormat:@"ORDER BY `%@` ASC", QKTestFieldOne]; - STAssertTrue([[_query query] hasSuffix:query], @"select query order by"); + STAssertTrue([[_query query] hasSuffix:query], @""); } - (void)testSelectQueryOrderByAscendingWithoutQuotesIsCorrect @@ -73,9 +73,10 @@ - (void)testSelectQueryOrderByMultipleFieldsAscendingIsCorrect { - [_query orderByFields:[NSArray arrayWithObjects:QKTestFieldOne, QKTestFieldTwo, nil] descending:NO]; - - NSString *query = [NSString stringWithFormat:@"ORDER BY `%@`, `%@` ASC", QKTestFieldOne, QKTestFieldTwo]; + [_query orderByField:QKTestFieldOne descending:NO]; + [_query orderByField:QKTestFieldTwo descending:NO]; + + NSString *query = [NSString stringWithFormat:@"ORDER BY `%@` ASC, `%@` ASC", QKTestFieldOne, QKTestFieldTwo]; STAssertTrue([[_query query] hasSuffix:query], @"select query order by multiple fields ascending when quoted"); } @@ -83,9 +84,11 @@ - (void)testSelectQueryOrderByMultipleFieldsAscendingWithoutQuotesIsCorrect { [_query setUseQuotedIdentifiers:NO]; - [_query orderByFields:[NSArray arrayWithObjects:QKTestFieldOne, QKTestFieldTwo, nil] descending:NO]; - NSString *query = [NSString stringWithFormat:@"ORDER BY %@, %@ ASC", QKTestFieldOne, QKTestFieldTwo]; + [_query orderByField:QKTestFieldOne descending:NO]; + [_query orderByField:QKTestFieldTwo descending:NO]; + + NSString *query = [NSString stringWithFormat:@"ORDER BY %@ ASC, %@ ASC", QKTestFieldOne, QKTestFieldTwo]; STAssertTrue([[_query query] hasSuffix:query], @"select query order by multiple fields ascending without quotes"); } @@ -111,9 +114,10 @@ - (void)testSelectQueryOrderByMultipleFieldsDescendingIsCorrect { - [_query orderByFields:[NSArray arrayWithObjects:QKTestFieldOne, QKTestFieldTwo, nil] descending:YES]; + [_query orderByField:QKTestFieldOne descending:YES]; + [_query orderByField:QKTestFieldTwo descending:YES]; - NSString *query = [NSString stringWithFormat:@"ORDER BY `%@`, `%@` DESC", QKTestFieldOne, QKTestFieldTwo]; + NSString *query = [NSString stringWithFormat:@"ORDER BY `%@` DESC, `%@` DESC", QKTestFieldOne, QKTestFieldTwo]; STAssertTrue([[_query query] hasSuffix:query], @"select query order by multiple fields descending"); } @@ -121,9 +125,11 @@ - (void)testSelectQueryOrderByMultipleFieldsDescendingWithoutQuotesIsCorrect { [_query setUseQuotedIdentifiers:NO]; - [_query orderByFields:[NSArray arrayWithObjects:QKTestFieldOne, QKTestFieldTwo, nil] descending:YES]; - NSString *query = [NSString stringWithFormat:@"ORDER BY %@, %@ DESC", QKTestFieldOne, QKTestFieldTwo]; + [_query orderByField:QKTestFieldOne descending:YES]; + [_query orderByField:QKTestFieldTwo descending:YES]; + + NSString *query = [NSString stringWithFormat:@"ORDER BY %@ DESC, %@ DESC", QKTestFieldOne, QKTestFieldTwo]; STAssertTrue([[_query query] hasSuffix:query], @"select query order by multiple fields descending without quotes"); } diff --git a/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m b/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m index 65c31dae..cd1fb848 100644 --- a/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m +++ b/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m @@ -78,6 +78,8 @@ { NSString *query = [NSString stringWithFormat:@"WHERE `%@` %@ %@", QKTestFieldOne, [QKQueryUtilities stringRepresentationOfQueryOperator:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]]; + NSLog(@"%@", [_query query]); + STAssertTrue(([[_query query] rangeOfString:query].location != NSNotFound), @"update query constraint"); } -- cgit v1.2.3