aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-07-09 09:27:48 +0000
committerstuconnolly <stuart02@gmail.com>2012-07-09 09:27:48 +0000
commitc1bab7abd666d809aa01c330a66c53e1b6abe6c4 (patch)
tree075fcdeb4b371e0fd1a21e74fa14ebf705860e2e /Frameworks/QueryKit/Tests/QKUpdateQueryTests.m
parenta434272a852db341a6ea4421e388ef924b6a99d7 (diff)
downloadsequelpro-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/QKUpdateQueryTests.m')
-rw-r--r--Frameworks/QueryKit/Tests/QKUpdateQueryTests.m39
1 files changed, 24 insertions, 15 deletions
diff --git a/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m b/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m
index fa3bb766..6a24881d 100644
--- a/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m
+++ b/Frameworks/QueryKit/Tests/QKUpdateQueryTests.m
@@ -29,21 +29,12 @@
// OTHER DEALINGS IN THE SOFTWARE.
#import "QKUpdateQueryTests.h"
-
-static NSString *QKTestTableName = @"test_table";
-
-static NSString *QKTestFieldOne = @"test_field1";
-static NSString *QKTestFieldTwo = @"test_field2";
-
-static NSString *QKTestUpdateValueOne = @"update_one";
-static NSString *QKTestUpdateValueTwo = @"update_two";
-
-static NSUInteger QKTestParameterOne = 10;
+#import "QKTestConstants.h"
@implementation QKUpdateQueryTests
#pragma mark -
-#pragma mark Setup & tear down
+#pragma mark Setup
- (void)setUp
{
@@ -62,21 +53,39 @@ static NSUInteger QKTestParameterOne = 10;
- (void)testUpdateQueryTypeIsCorrect
{
- STAssertTrue([[_query query] hasPrefix:@"UPDATE"], @"query type");
+ STAssertTrue([[_query query] hasPrefix:@"UPDATE"], @"update query type");
}
- (void)testUpdateQueryFieldsAreCorrect
{
+ NSString *query = [NSString stringWithFormat:@"UPDATE `%@` SET `%@` = '%@', `%@` = '%@'", QKTestTableName, QKTestFieldOne, QKTestUpdateValueOne, QKTestFieldTwo, QKTestUpdateValueTwo];
+
+ STAssertTrue([[_query query] hasPrefix:query], @"update query fields");
+}
+
+- (void)testUpdateQueryFieldsWithoutQuotesAreCorrect
+{
+ [_query setUseQuotes:NO];
+
NSString *query = [NSString stringWithFormat:@"UPDATE %@ SET %@ = '%@', %@ = '%@'", QKTestTableName, QKTestFieldOne, QKTestUpdateValueOne, QKTestFieldTwo, QKTestUpdateValueTwo];
+
+ STAssertTrue([[_query query] hasPrefix:query], @"update query fields without quotes");
+}
+
+- (void)testUpdateQueryConstraintIsCorrect
+{
+ NSString *query = [NSString stringWithFormat:@"WHERE `%@` %@ %@", QKTestFieldOne, [QKQueryUtilities operatorRepresentationForType:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]];
- STAssertTrue([[_query query] hasPrefix:query], @"query fields");
+ STAssertTrue(([[_query query] rangeOfString:query].location != NSNotFound), @"update query constraint");
}
-- (void)testUpdateQueryConstraintsAreCorrect
+- (void)testUpdateQueryConstraintWithoutQuotesIsCorrect
{
+ [_query setUseQuotes:NO];
+
NSString *query = [NSString stringWithFormat:@"WHERE %@ %@ %@", QKTestFieldOne, [QKQueryUtilities operatorRepresentationForType:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]];
- STAssertTrue(([[_query query] rangeOfString:query].location != NSNotFound), @"query constraints");
+ STAssertTrue(([[_query query] rangeOfString:query].location != NSNotFound), @"update query constraint without quotes");
}
@end