diff options
author | jakob <jakob@eggerapps.at> | 2009-03-24 18:43:58 +0000 |
---|---|---|
committer | jakob <jakob@eggerapps.at> | 2009-03-24 18:43:58 +0000 |
commit | a23bb9169015b21191bf072a7da6c668991907df (patch) | |
tree | e9077cf72f071f9f46299669f6535987b56ae402 /Source/TableDocument.m | |
parent | d09e3a2a855c80a5a69017a53a7d62e5324f0c26 (diff) | |
download | sequelpro-a23bb9169015b21191bf072a7da6c668991907df.tar.gz sequelpro-a23bb9169015b21191bf072a7da6c668991907df.tar.bz2 sequelpro-a23bb9169015b21191bf072a7da6c668991907df.zip |
- fixed issue #203 (backticks in identifiers not supported)
- added a backtickQuotedString: method to SPStringAdditions
- created the file SPArrayAdditions for a componentsJoinedAndBacktickQuoted: method
In the future, we should use backtickQuotedString: to quote identifiers like this:
[NSString stringWithFormat:@"SELECT * FROM %@", [tableName backtickQuotedString]]
Diffstat (limited to 'Source/TableDocument.m')
-rw-r--r-- | Source/TableDocument.m | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 8596f60b..c4179fb4 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -36,6 +36,7 @@ #import "SPQueryConsole.h" #import "SPSQLParser.h" #import "SPTableData.h" +#import "SPStringAdditions.h" NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocumentFavoritesControllerSelectionIndexDidChange"; NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFavoritesControllerFavoritesDidChange"; @@ -412,7 +413,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa if (returnCode != NSAlertDefaultReturn) return; - [mySQLConnection queryString:[NSString stringWithFormat:@"DROP DATABASE `%@`", [self database]]]; + [mySQLConnection queryString:[NSString stringWithFormat:@"DROP DATABASE %@", [[self database] backtickQuotedString]]]; if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { // error while deleting db NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove database.\nMySQL said: %@", @"message of panel when removing db failed"), [mySQLConnection getLastErrorMessage]]); @@ -535,11 +536,11 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa return; } - NSString *createStatement = [NSString stringWithFormat:@"CREATE DATABASE `%@`", [databaseNameField stringValue]]; + NSString *createStatement = [NSString stringWithFormat:@"CREATE DATABASE %@", [[databaseNameField stringValue] backtickQuotedString]]; // If there is an encoding selected other than the default we must specify it in CREATE DATABASE statement if ([databaseEncodingButton indexOfSelectedItem] > 0) { - createStatement = [NSString stringWithFormat:@"%@ DEFAULT CHARACTER SET `%@`", createStatement, [self mysqlEncodingFromDisplayEncoding:[databaseEncodingButton title]]]; + createStatement = [NSString stringWithFormat:@"%@ DEFAULT CHARACTER SET %@", createStatement, [[self mysqlEncodingFromDisplayEncoding:[databaseEncodingButton title]] backtickQuotedString]]; } // Create the database @@ -787,7 +788,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa - (IBAction)showCreateTableSyntax:(id)sender { //Create the query and get results - NSString *query = [NSString stringWithFormat:@"SHOW CREATE TABLE `%@`", [self table]]; + NSString *query = [NSString stringWithFormat:@"SHOW CREATE TABLE %@", [[self table] backtickQuotedString]]; CMMCPResult *theResult = [mySQLConnection queryString:query]; // Check for errors @@ -808,7 +809,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa - (IBAction)copyCreateTableSyntax:(id)sender { // Create the query and get results - NSString *query = [NSString stringWithFormat:@"SHOW CREATE TABLE `%@`", [self table]]; + NSString *query = [NSString stringWithFormat:@"SHOW CREATE TABLE %@", [[self table] backtickQuotedString]]; CMMCPResult *theResult = [mySQLConnection queryString:query]; // Check for errors @@ -840,7 +841,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa NSDictionary *theRow; //Create the query and get results - query = [NSString stringWithFormat:@"CHECK TABLE `%@`", [self table]]; + query = [NSString stringWithFormat:@"CHECK TABLE %@", [[self table] backtickQuotedString]]; theResult = [mySQLConnection queryString:query]; // Check for errors @@ -861,7 +862,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa NSDictionary *theRow; //Create the query and get results - query = [NSString stringWithFormat:@"ANALYZE TABLE `%@`", [self table]]; + query = [NSString stringWithFormat:@"ANALYZE TABLE %@", [[self table] backtickQuotedString]]; theResult = [mySQLConnection queryString:query]; // Check for errors @@ -882,7 +883,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa NSDictionary *theRow; //Create the query and get results - query = [NSString stringWithFormat:@"OPTIMIZE TABLE `%@`", [self table]]; + query = [NSString stringWithFormat:@"OPTIMIZE TABLE %@", [[self table] backtickQuotedString]]; theResult = [mySQLConnection queryString:query]; // Check for errors @@ -902,7 +903,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa NSDictionary *theRow; //Create the query and get results - query = [NSString stringWithFormat:@"REPAIR TABLE `%@`", [self table]]; + query = [NSString stringWithFormat:@"REPAIR TABLE %@", [[self table] backtickQuotedString]]; theResult = [mySQLConnection queryString:query]; // Check for errors @@ -921,7 +922,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa CMMCPResult *theResult; //Create the query and get results - query = [NSString stringWithFormat:@"FLUSH TABLE `%@`", [self table]]; + query = [NSString stringWithFormat:@"FLUSH TABLE %@", [[self table] backtickQuotedString]]; theResult = [mySQLConnection queryString:query]; // Check for errors @@ -941,7 +942,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa NSDictionary *theRow; //Create the query and get results - query = [NSString stringWithFormat:@"CHECKSUM TABLE `%@`", [self table]]; + query = [NSString stringWithFormat:@"CHECKSUM TABLE %@", [[self table] backtickQuotedString]]; theResult = [mySQLConnection queryString:query]; // Check for errors |