diff options
author | stuconnolly <stuart02@gmail.com> | 2012-07-09 09:27:48 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2012-07-09 09:27:48 +0000 |
commit | c1bab7abd666d809aa01c330a66c53e1b6abe6c4 (patch) | |
tree | 075fcdeb4b371e0fd1a21e74fa14ebf705860e2e /Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m | |
parent | a434272a852db341a6ea4421e388ef924b6a99d7 (diff) | |
download | sequelpro-c1bab7abd666d809aa01c330a66c53e1b6abe6c4.tar.gz sequelpro-c1bab7abd666d809aa01c330a66c53e1b6abe6c4.tar.bz2 sequelpro-c1bab7abd666d809aa01c330a66c53e1b6abe6c4.zip |
Improve QueryKit's handling of quotes by making it on by default. Also, add a bunch more tests.
Diffstat (limited to 'Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m')
-rw-r--r-- | Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m b/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m index c34b586a..e9edbea1 100644 --- a/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m +++ b/Frameworks/QueryKit/Tests/QKSelectQueryGroupByTests.m @@ -29,16 +29,12 @@ // OTHER DEALINGS IN THE SOFTWARE. #import "QKSelectQueryGroupByTests.h" - -static NSString *QKTestTableName = @"test_table"; - -static NSString *QKTestFieldOne = @"test_field1"; -static NSString *QKTestFieldTwo = @"test_field2"; +#import "QKTestConstants.h" @implementation QKSelectQueryGroupByTests #pragma mark - -#pragma mark Setup & tear down +#pragma mark Setup - (void)setUp { @@ -53,26 +49,45 @@ static NSString *QKTestFieldTwo = @"test_field2"; - (void)testSelectQueryTypeIsCorrect { - STAssertTrue([[_query query] hasPrefix:@"SELECT"], @"query type"); + STAssertTrue([[_query query] hasPrefix:@"SELECT"], @"select query type"); } - (void)testSelectQueryGroupByIsCorrect { [_query groupByField:QKTestFieldOne]; + NSString *query = [NSString stringWithFormat:@"GROUP BY `%@`", QKTestFieldOne]; + + STAssertTrue([[_query query] hasSuffix:query], @"select query group by"); +} + +- (void)testSelectQueryGroupByWithoutQuotesIsCorrect +{ + [_query setUseQuotes:NO]; + [_query groupByField:QKTestFieldOne]; + NSString *query = [NSString stringWithFormat:@"GROUP BY %@", QKTestFieldOne]; - STAssertTrue([[_query query] hasSuffix:query], @"query group by"); + STAssertTrue([[_query query] hasSuffix:query], @"select query group by without quotes"); } - (void)testSelectQueryGroupByMultipleFieldsIsCorrect { [_query groupByFields:[NSArray arrayWithObjects:QKTestFieldOne, QKTestFieldTwo, nil]]; - NSString *query = [NSString stringWithFormat:@"GROUP BY %@, %@", QKTestFieldOne, QKTestFieldTwo]; + NSString *query = [NSString stringWithFormat:@"GROUP BY `%@`, `%@`", QKTestFieldOne, QKTestFieldTwo]; - STAssertTrue([[_query query] hasSuffix:query], @"query group by"); + STAssertTrue([[_query query] hasSuffix:query], @"select query group by multiple fields"); } +- (void)testSelectQueryGroupByMultipleFieldsWithoutQuotesIsCorrect +{ + [_query setUseQuotes:NO]; + [_query groupByFields:[NSArray arrayWithObjects:QKTestFieldOne, QKTestFieldTwo, nil]]; + + NSString *query = [NSString stringWithFormat:@"GROUP BY %@, %@", QKTestFieldOne, QKTestFieldTwo]; + + STAssertTrue([[_query query] hasSuffix:query], @"select query group by multiple fields without quotes"); +} @end |