aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMCopyTable.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-06-23 07:31:58 +0000
committerBibiko <bibiko@eva.mpg.de>2009-06-23 07:31:58 +0000
commit05972454d49ec13c7dfc075528d3c092d06ce9a8 (patch)
tree0b32240da24ff585c171e2cfcb95ebdf0fbf2353 /Source/CMCopyTable.m
parent5b7810fcc6b6bfd917ce159b1762718c8e8455bf (diff)
downloadsequelpro-05972454d49ec13c7dfc075528d3c092d06ce9a8.tar.gz
sequelpro-05972454d49ec13c7dfc075528d3c092d06ce9a8.tar.bz2
sequelpro-05972454d49ec13c7dfc075528d3c092d06ce9a8.zip
• fixed: make usage of backtickQuotedString to allow table names containing a `
• some minor code cleaning and commenting
Diffstat (limited to 'Source/CMCopyTable.m')
-rw-r--r--Source/CMCopyTable.m17
1 files changed, 9 insertions, 8 deletions
diff --git a/Source/CMCopyTable.m b/Source/CMCopyTable.m
index 1ed22248..01f4f4a7 100644
--- a/Source/CMCopyTable.m
+++ b/Source/CMCopyTable.m
@@ -24,6 +24,7 @@
#import "CMCopyTable.h"
#import "SPArrayAdditions.h"
+#import "SPStringAdditions.h"
#import "CMMCPConnection.h"
#import "TableContent.h"
#import "CustomQuery.h"
@@ -208,8 +209,8 @@ int MENU_EDIT_COPY_AS_SQL = 2002;
[types addObject:[NSNumber numberWithInt:1]]; // string (fallback coevally)
}
- [result appendString:[NSString stringWithFormat:@"INSERT INTO `%@` (%@)\nVALUES\n",
- (selectedTable == nil)?@"<table>":selectedTable, [tbHeader componentsJoinedAndBacktickQuoted]]];
+ [result appendString:[NSString stringWithFormat:@"INSERT INTO %@ (%@)\nVALUES\n",
+ [(selectedTable == nil)?@"<table>":selectedTable backtickQuotedString], [tbHeader componentsJoinedAndBacktickQuoted]]];
//this is really deprecated in 10.3, but the new method is really weird
NSEnumerator *enumerator = [self selectedRowEnumerator];
@@ -249,8 +250,8 @@ int MENU_EDIT_COPY_AS_SQL = 2002;
//if we have indexes, use argumentForRow
dbDataRow = [[mySQLConnection queryString:
- [NSString stringWithFormat:@"SELECT * FROM `%@` WHERE %@",
- selectedTable, [tableInstance argumentForRow:row]]] fetchRowAsDictionary];
+ [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@",
+ [selectedTable backtickQuotedString], [tableInstance argumentForRow:row]]] fetchRowAsDictionary];
if([[dbDataRow objectForKey:[tbHeader objectAtIndex:c]] isKindOfClass:[NSNull class]])
[value appendString:@"NULL, "];
else
@@ -269,8 +270,8 @@ int MENU_EDIT_COPY_AS_SQL = 2002;
//if we have indexes, use argumentForRow
dbDataRow = [[mySQLConnection queryString:
- [NSString stringWithFormat:@"SELECT * FROM `%@` WHERE %@",
- selectedTable, [tableInstance argumentForRow:row]]] fetchRowAsDictionary];
+ [NSString stringWithFormat:@"SELECT * FROM %@ WHERE %@",
+ [selectedTable backtickQuotedString], [tableInstance argumentForRow:row]]] fetchRowAsDictionary];
if([[dbDataRow objectForKey:[tbHeader objectAtIndex:c]] isKindOfClass:[NSNull class]])
[value appendString:@"NULL, "];
else
@@ -302,8 +303,8 @@ int MENU_EDIT_COPY_AS_SQL = 2002;
// Add a new INSERT starter command every ~250k of data.
if ( valueLength > 250000 ) {
[result appendString:value];
- [result appendString:[NSString stringWithFormat:@");\n\nINSERT INTO `%@` (%@)\nVALUES\n",
- (selectedTable == nil)?@"<table>":selectedTable, [tbHeader componentsJoinedAndBacktickQuoted]]];
+ [result appendString:[NSString stringWithFormat:@");\n\nINSERT INTO %@ (%@)\nVALUES\n",
+ [(selectedTable == nil)?@"<table>":selectedTable backtickQuotedString], [tbHeader componentsJoinedAndBacktickQuoted]]];
[value setString:@""];
valueLength = 0;
} else {