aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/QueryKit/Tests
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-07-15 10:15:11 +0000
committerstuconnolly <stuart02@gmail.com>2012-07-15 10:15:11 +0000
commitcb00d18102f8c3f88e8a15bb4d9fb7825cf29a59 (patch)
tree8c266026ae92013dbc028a09d7d98e22bbcfbd5f /Frameworks/QueryKit/Tests
parentdd2c7e34d265c7a4a66b7583a186456095b545ee (diff)
downloadsequelpro-cb00d18102f8c3f88e8a15bb4d9fb7825cf29a59.tar.gz
sequelpro-cb00d18102f8c3f88e8a15bb4d9fb7825cf29a59.tar.bz2
sequelpro-cb00d18102f8c3f88e8a15bb4d9fb7825cf29a59.zip
Add a new order by class.
Diffstat (limited to 'Frameworks/QueryKit/Tests')
-rw-r--r--Frameworks/QueryKit/Tests/QKSelectQueryOrderByTests.m28
-rw-r--r--Frameworks/QueryKit/Tests/QKUpdateQueryTests.m2
2 files changed, 19 insertions, 11 deletions
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");
}