aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-08-20 10:02:00 +0000
committerBibiko <bibiko@eva.mpg.de>2010-08-20 10:02:00 +0000
commitd17a6b638e529694685a333162bbf6fec6c7fc08 (patch)
tree5c72506af7bf75299c093ce6a47b7cc4a956e0ff
parentdabf6466f11e5936ee871b8b3dd573020a142586 (diff)
downloadsequelpro-d17a6b638e529694685a333162bbf6fec6c7fc08.tar.gz
sequelpro-d17a6b638e529694685a333162bbf6fec6c7fc08.tar.bz2
sequelpro-d17a6b638e529694685a333162bbf6fec6c7fc08.zip
• overall replacement of:
[aString appendString:[NSString stringWithFormat:]] by [aString appendFormat:] since it's much more faster • first look at loop where several [aStr appendString:] occur to try to combine them into one appendString or appendFormat since the allocation of memory takes really time Note: I tested all my changes but we should test it further to be sure that I didn't a mistake!
-rw-r--r--Source/SPCopyTable.m58
-rw-r--r--Source/SPCustomQuery.m28
-rw-r--r--Source/SPDataAdditions.m19
-rw-r--r--Source/SPDataImport.m16
-rw-r--r--Source/SPDotExporter.m36
-rw-r--r--Source/SPExportFileUtilities.m12
-rw-r--r--Source/SPLogger.m2
-rw-r--r--Source/SPNarrowDownCompletion.m6
-rw-r--r--Source/SPQueryController.m43
-rw-r--r--Source/SPSQLExporter.m69
-rw-r--r--Source/SPServerVariablesController.m2
-rw-r--r--Source/SPTableContent.m16
-rw-r--r--Source/SPTableStructure.m24
-rw-r--r--Source/SPUserManager.m22
14 files changed, 162 insertions, 191 deletions
diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m
index 6a65a934..d37a0b73 100644
--- a/Source/SPCopyTable.m
+++ b/Source/SPCopyTable.m
@@ -125,9 +125,9 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
if (withHeaders) {
NSUInteger i;
for( i = 0; i < numColumns; i++ ){
- [result appendString:[NSString stringWithFormat:@"%@\t", [[NSArrayObjectAtIndex(columns, i) headerCell] stringValue]]];
+ [result appendFormat:@"%@\t", [[NSArrayObjectAtIndex(columns, i) headerCell] stringValue]];
}
- [result appendString:[NSString stringWithFormat:@"\n"]];
+ [result appendString:@"\n"];
}
NSUInteger c;
@@ -141,6 +141,8 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
// Loop through the rows, adding their descriptive contents
NSUInteger rowIndex = [selectedRows firstIndex];
+ NSString * nullString = [prefs objectForKey:SPNullValue];
+ NSStringEncoding connectionEncoding = [mySQLConnection encoding];
while ( rowIndex != NSNotFound )
{
for ( c = 0; c < numColumns; c++) {
@@ -150,19 +152,18 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
// and the string representation of any blobs or binary texts.
if (cellData) {
if ([cellData isNSNull])
- [result appendString:[NSString stringWithFormat:@"%@\t", [prefs objectForKey:SPNullValue]]];
+ [result appendFormat:@"%@\t", nullString];
else if ([cellData isSPNotLoaded])
- [result appendString:[NSString stringWithFormat:@"%@\t", NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields")]];
+ [result appendFormat:@"%@\t", NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields")];
else if ([cellData isKindOfClass:[NSData class]]) {
- NSString *displayString = [[NSString alloc] initWithData:cellData encoding:[mySQLConnection encoding]];
+ NSString *displayString = [[NSString alloc] initWithData:cellData encoding:connectionEncoding];
if (!displayString) displayString = [[NSString alloc] initWithData:cellData encoding:NSASCIIStringEncoding];
if (displayString) {
- [result appendString:displayString];
+ [result appendFormat:@"%@\t", displayString];
[displayString release];
- [result appendString:@"\t"];
}
} else
- [result appendString:[NSString stringWithFormat:@"%@\t", [cellData description]]];
+ [result appendFormat:@"%@\t", [cellData description]];
} else {
[result appendString:@"\t"];
}
@@ -172,7 +173,7 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
if ([result length]){
[result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
}
- [result appendString:[NSString stringWithFormat:@"\n"]];
+ [result appendString:@"\n"];
// Select the next row index
rowIndex = [selectedRows indexGreaterThanIndex:rowIndex];
@@ -240,10 +241,12 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
}
// Begin the SQL string
- [result appendString:[NSString stringWithFormat:@"INSERT INTO %@ (%@)\nVALUES\n",
- [(selectedTable == nil)?@"<table>":selectedTable backtickQuotedString], [tbHeader componentsJoinedAndBacktickQuoted]]];
+ [result appendFormat:@"INSERT INTO %@ (%@)\nVALUES\n",
+ [(selectedTable == nil)?@"<table>":selectedTable backtickQuotedString], [tbHeader componentsJoinedAndBacktickQuoted]];
NSUInteger rowIndex = [selectedRows firstIndex];
+ Class spTableContentClass = [SPTableContent class];
+ Class nsDataClass = [NSData class];
while ( rowIndex != NSNotFound )
{
[value appendString:@"\t("];
@@ -254,10 +257,10 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
cellData = SPDataStorageObjectAtRowAndColumn(tableStorage, rowIndex, columnMappings[c]);
// If the data is not loaded, attempt to fetch the value
- if ([cellData isSPNotLoaded] && [[self delegate] isKindOfClass:[SPTableContent class]]) {
+ if ([cellData isSPNotLoaded] && [[self delegate] isKindOfClass:spTableContentClass]) {
// Abort if no table name given, not table content, or if there are no indices on this table
- if (!selectedTable || ![[self delegate] isKindOfClass:[SPTableContent class]] || ![[tableInstance argumentForRow:rowIndex] length]) {
+ if (!selectedTable || ![[self delegate] isKindOfClass:spTableContentClass] || ![[tableInstance argumentForRow:rowIndex] length]) {
NSBeep();
free(columnMappings);
free(columnTypes);
@@ -268,7 +271,7 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
// TODO - this could be preloaded for all selected rows rather than cell-by-cell
cellData = [mySQLConnection getFirstFieldFromQuery:
[NSString stringWithFormat:@"SELECT %@ FROM %@ WHERE %@",
- [[tbHeader objectAtIndex:columnMappings[c]] backtickQuotedString],
+ [NSArrayObjectAtIndex(tbHeader, columnMappings[c]) backtickQuotedString],
[selectedTable backtickQuotedString],
[tableInstance argumentForRow:rowIndex]]];
}
@@ -285,16 +288,16 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
// Convert numeric types to unquoted strings
case 0:
- [value appendString:[NSString stringWithFormat:@"%@, ", [cellData description]]];
+ [value appendFormat:@"%@, ", [cellData description]];
break;
// Quote string, text and blob types appropriately
case 1:
case 2:
- if ([cellData isKindOfClass:[NSData class]]) {
- [value appendString:[NSString stringWithFormat:@"X'%@', ", [mySQLConnection prepareBinaryData:cellData]]];
+ if ([cellData isKindOfClass:nsDataClass]) {
+ [value appendFormat:@"X'%@', ", [mySQLConnection prepareBinaryData:cellData]];
} else {
- [value appendString:[NSString stringWithFormat:@"'%@', ", [mySQLConnection prepareString:[cellData description]]]];
+ [value appendFormat:@"'%@', ", [mySQLConnection prepareString:[cellData description]]];
}
break;
@@ -326,9 +329,7 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
// 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 backtickQuotedString], [tbHeader componentsJoinedAndBacktickQuoted]]];
+ [result appendFormat:@"%@);\n\nINSERT INTO %@ (%@)\nVALUES\n", value, [(selectedTable == nil)?@"<table>":selectedTable backtickQuotedString], [tbHeader componentsJoinedAndBacktickQuoted]];
[value setString:@""];
valueLength = 0;
} else {
@@ -378,6 +379,9 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
// Loop through the rows, adding their descriptive contents
NSUInteger rowIndex = [selectedRows firstIndex];
+ NSString *nullString = [prefs objectForKey:SPNullValue];
+ Class nsDataClass = [NSData class];
+ NSStringEncoding connectionEncoding = [mySQLConnection encoding];
while ( rowIndex != NSNotFound )
{
for ( c = 0; c < numColumns; c++) {
@@ -387,18 +391,18 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
// and the string representation of any blobs or binary texts.
if (cellData) {
if ([cellData isNSNull])
- [result appendString:[NSString stringWithFormat:@"%@\t", [prefs objectForKey:SPNullValue]]];
+ [result appendFormat:@"%@\t", nullString];
else if ([cellData isSPNotLoaded])
- [result appendString:[NSString stringWithFormat:@"%@\t", NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields")]];
- else if ([cellData isKindOfClass:[NSData class]]) {
- NSString *displayString = [[NSString alloc] initWithData:cellData encoding:[mySQLConnection encoding]];
+ [result appendFormat:@"%@\t", NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields")];
+ else if ([cellData isKindOfClass:nsDataClass]) {
+ NSString *displayString = [[NSString alloc] initWithData:cellData encoding:connectionEncoding];
if (!displayString) displayString = [[NSString alloc] initWithData:cellData encoding:NSASCIIStringEncoding];
if (displayString) {
[result appendString:displayString];
[displayString release];
}
} else
- [result appendString:[NSString stringWithFormat:@"%@\t", [cellData description]]];
+ [result appendFormat:@"%@\t", [cellData description]];
} else {
[result appendString:@"\t"];
}
@@ -408,7 +412,7 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
[result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
}
- [result appendString:[NSString stringWithFormat:@"\n"]];
+ [result appendString:@"\n"];
// Retrieve the next selected row index
rowIndex = [selectedRows indexGreaterThanIndex:rowIndex];
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index 31aaea54..80ec1c33 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -652,9 +652,9 @@
if(!suppressErrorSheet)
{
// Update error text for the user
- [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"),
+ [errors appendFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"),
(long)(i+1),
- errorString]];
+ errorString];
[[errorText onMainThread] setStringValue:errors];
// ask the user to continue after detecting an error
@@ -682,9 +682,9 @@
}
}
} else {
- [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"),
+ [errors appendFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"),
(long)(i+1),
- errorString]];
+ errorString];
}
} else {
[errors setString:errorString];
@@ -2818,18 +2818,14 @@
// break;
// }
- [theHelp appendString:@"<pre class='description'>"];
- [theHelp appendString:desc];
- [theHelp appendString:@"</pre>"];
+ [theHelp appendFormat:@"<pre class='description'>%@</pre>", desc];
}
// are examples available?
if([tableDetails objectForKey:@"example"]){
NSString *examples = [[[tableDetails objectForKey:@"example"] copy] autorelease];
- if([examples length]){
- [theHelp appendString:@"<br><i><b>Example:</b></i><br><pre class='example'>"];
- [theHelp appendString:examples];
- [theHelp appendString:@"</pre>"];
- }
+ if([examples length])
+ [theHelp appendFormat:@"<br><i><b>Example:</b></i><br><pre class='example'>%@</pre>", examples];
+
}
} else { // list all found topics
NSInteger i;
@@ -2837,17 +2833,17 @@
if (r) [theResult dataSeek:0];
// check if HELP 'contents' is called
if(![searchString isEqualToString:SP_HELP_TOC_SEARCH_STRING])
- [theHelp appendString:[NSString stringWithFormat:@"<br><i>%@ “%@”</i><br>", NSLocalizedString(@"Help topics for", @"help topics for"), searchString]];
+ [theHelp appendFormat:@"<br><i>%@ “%@”</i><br>", NSLocalizedString(@"Help topics for", @"help topics for"), searchString];
else
- [theHelp appendString:[NSString stringWithFormat:@"<br><b>%@:</b><br>", NSLocalizedString(@"MySQL Help – Categories", @"mysql help categories"), searchString]];
+ [theHelp appendFormat:@"<br><b>%@:</b><br>", NSLocalizedString(@"MySQL Help – Categories", @"mysql help categories"), searchString];
// iterate through all found rows and print them as HTML ul/li list
[theHelp appendString:@"<ul>"];
for ( i = 0 ; i < r ; i++ ) {
NSArray *anArray = [theResult fetchRowAsArray];
NSString *topic = [anArray objectAtIndex:[anArray count]-2];
- [theHelp appendString:
- [NSString stringWithFormat:@"<li><a title='%@ “%@”' href='%@' class='internallink'>%@</a></li>", NSLocalizedString(@"Show MySQL help for", @"show mysql help for"), topic, topic, topic]];
+ [theHelp appendFormat:@"<li><a title='%@ “%@”' href='%@' class='internallink'>%@</a></li>",
+ NSLocalizedString(@"Show MySQL help for", @"show mysql help for"), topic, topic, topic];
}
[theHelp appendString:@"</ul>"];
}
diff --git a/Source/SPDataAdditions.m b/Source/SPDataAdditions.m
index b8f4ee3a..b482357a 100644
--- a/Source/SPDataAdditions.m
+++ b/Source/SPDataAdditions.m
@@ -285,7 +285,7 @@ static char base64encodingTable[64] = {
NSUInteger buffLength = bytesPerLine;
// add hex value of location
- [location appendString:[NSString stringWithFormat:@"%X", i]];
+ [location appendFormat:@"%X", i];
// pad it
while( longest > [location length] ) {
@@ -304,7 +304,7 @@ static char base64encodingTable[64] = {
// build the hex string
for ( j = 0; j < buffLength; j++ ) {
- [hex appendString:[NSString stringWithFormat:@"%02X ", *(buffer + j)]];
+ [hex appendFormat:@"%02X ", *(buffer + j)];
// Replace non-displayed bytes by '.'
// non-displayed bytes are all bytes whose hex code is less than 0x20
@@ -320,7 +320,7 @@ static char base64encodingTable[64] = {
}
// build line
- [retVal appendFormat:@"%@ %@ %@\n", location, hex, [NSString stringWithFormat:@"%s", buffer]];
+ [retVal appendFormat:@"%@ %@ %s\n", location, hex, buffer];
// clean up
[hex release];
@@ -338,20 +338,19 @@ static char base64encodingTable[64] = {
*/
- (NSString *) shortStringRepresentationUsingEncoding:(NSStringEncoding)encoding
{
- NSString *tmp = [[NSString alloc] initWithData:self encoding:encoding];
- NSString *shortString;
+ NSString *tmp = [[[NSString alloc] initWithData:self encoding:encoding] autorelease];
+
if (tmp == nil)
tmp = [[NSString alloc] initWithData:self encoding:NSASCIIStringEncoding];
if (tmp == nil)
return @"- cannot be displayed -";
else {
- if([tmp length]>255)
- shortString = [[NSString stringWithString:tmp] substringToIndex:255];
+ if([tmp length] > 255)
+ return [tmp substringToIndex:255];
else
- shortString = [NSString stringWithString:tmp];
+ return tmp;
}
- [tmp release];
- return shortString;
+ return @"- cannot be displayed -";
}
@end
diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m
index e697ec18..ac1eadc0 100644
--- a/Source/SPDataImport.m
+++ b/Source/SPDataImport.m
@@ -549,7 +549,7 @@
// Check for any errors
if ([mySQLConnection queryErrored] && ![[mySQLConnection getLastErrorMessage] isEqualToString:@"Query was empty"]) {
- [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"), (long)(queriesPerformed+1), [mySQLConnection getLastErrorMessage]]];
+ [errors appendFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"), (long)(queriesPerformed+1), [mySQLConnection getLastErrorMessage]];
}
// Increment the processed queries count
@@ -584,7 +584,7 @@
// Check for any errors
if ([mySQLConnection queryErrored] && ![[mySQLConnection getLastErrorMessage] isEqualToString:@"Query was empty"]) {
- [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"), (long)(queriesPerformed+1), [mySQLConnection getLastErrorMessage]]];
+ [errors appendFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"), (long)(queriesPerformed+1), [mySQLConnection getLastErrorMessage]];
}
// Increment the processed queries count
@@ -972,9 +972,9 @@
if ([mySQLConnection queryErrored]) {
[tableDocumentInstance showConsole:nil];
- [errors appendString:[NSString stringWithFormat:
+ [errors appendFormat:
NSLocalizedString(@"[ERROR in row %ld] %@\n", @"error text when reading of csv file gave errors"),
- (long)(rowsImported+1),[mySQLConnection getLastErrorMessage]]];
+ (long)(rowsImported+1),[mySQLConnection getLastErrorMessage]];
}
if ( insertRemainingRowsAfterUpdate && ![mySQLConnection affectedRows]) {
@@ -989,9 +989,9 @@
[query release];
if ([mySQLConnection queryErrored]) {
- [errors appendString:[NSString stringWithFormat:
+ [errors appendFormat:
NSLocalizedString(@"[ERROR in row %ld] %@\n", @"error text when reading of csv file gave errors"),
- (long)(rowsImported+1),[mySQLConnection getLastErrorMessage]]];
+ (long)(rowsImported+1),[mySQLConnection getLastErrorMessage]];
}
}
@@ -1019,9 +1019,9 @@
[query release];
if ([mySQLConnection queryErrored]) {
- [errors appendString:[NSString stringWithFormat:
+ [errors appendFormat:
NSLocalizedString(@"[ERROR in row %ld] %@\n", @"error text when reading of csv file gave errors"),
- (long)(rowsImported+1),[mySQLConnection getLastErrorMessage]]];
+ (long)(rowsImported+1),[mySQLConnection getLastErrorMessage]];
}
rowsImported++;
[singleProgressBar setDoubleValue:[[parsePositions objectAtIndex:i] doubleValue]];
diff --git a/Source/SPDotExporter.m b/Source/SPDotExporter.m
index a2db43af..98644f32 100644
--- a/Source/SPDotExporter.m
+++ b/Source/SPDotExporter.m
@@ -83,15 +83,15 @@
[metaString setString:@"// ************************************************************\n"];
[metaString appendString:@"// Generated by: Sequel Pro\n"];
- [metaString appendString:[NSString stringWithFormat:@"// Version %@\n//\n", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]]];
- [metaString appendString:[NSString stringWithFormat:@"// %@\n// %@\n//\n", SPLOCALIZEDURL_HOMEPAGE, SPDevURL]];
- [metaString appendString:[NSString stringWithFormat:@"// Host: %@ (MySQL %@)\n", [self dotDatabaseHost], [self dotDatabaseVersion]]];
- [metaString appendString:[NSString stringWithFormat:@"// Database: %@\n", [self dotDatabaseName]]];
- [metaString appendString:[NSString stringWithFormat:@"// Generation Time: %@\n", [NSDate date]]];
+ [metaString appendFormat:@"// Version %@\n//\n", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
+ [metaString appendFormat:@"// %@\n// %@\n//\n", SPLOCALIZEDURL_HOMEPAGE, SPDevURL];
+ [metaString appendFormat:@"// Host: %@ (MySQL %@)\n", [self dotDatabaseHost], [self dotDatabaseVersion]];
+ [metaString appendFormat:@"// Database: %@\n", [self dotDatabaseName]];
+ [metaString appendFormat:@"// Generation Time: %@\n", [NSDate date]];
[metaString appendString:@"// ************************************************************\n\n"];
[metaString appendString:@"digraph \"Database Structure\" {\n"];
- [metaString appendString:[NSString stringWithFormat:@"\tlabel = \"ER Diagram: %@\";\n", [self dotDatabaseName]]];
+ [metaString appendFormat:@"\tlabel = \"ER Diagram: %@\";\n", [self dotDatabaseName]];
[metaString appendString:@"\tlabelloc = t;\n"];
[metaString appendString:@"\tcompound = true;\n"];
[metaString appendString:@"\tnode [ shape = record ];\n"];
@@ -132,16 +132,16 @@
[metaString setString:[NSString stringWithFormat:@"\tsubgraph \"table_%@\" {\n", tableName]];
[metaString appendString:@"\t\tnode [ shape = \"plaintext\" ];\n"];
- [metaString appendString:[NSString stringWithFormat:@"\t\t\"%@\" [ label=<\n", tableName]];
+ [metaString appendFormat:@"\t\t\"%@\" [ label=<\n", tableName];
[metaString appendString:@"\t\t\t<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLBORDER=\"1\">\n"];
- [metaString appendString:[NSString stringWithFormat:@"\t\t\t<TR><TD COLSPAN=\"3\" BGCOLOR=\"%@\">%@</TD></TR>\n", hdrColor, tableName]];
+ [metaString appendFormat:@"\t\t\t<TR><TD COLSPAN=\"3\" BGCOLOR=\"%@\">%@</TD></TR>\n", hdrColor, tableName];
// Get the column info
NSArray *columnInfo = [tableInfo objectForKey:@"columns"];
- for (NSInteger j = 0; j < [columnInfo count]; j++ )
+ for (NSDictionary* item in columnInfo)
{
- [metaString appendString:[NSString stringWithFormat:@"\t\t\t<TR><TD COLSPAN=\"3\" PORT=\"%@\">%@:<FONT FACE=\"Helvetica-Oblique\" POINT-SIZE=\"10\">%@</FONT></TD></TR>\n", [[columnInfo objectAtIndex:j] objectForKey:@"name"], [[columnInfo objectAtIndex:j] objectForKey:@"name"], [[columnInfo objectAtIndex:j] objectForKey:@"type"]]];
+ [metaString appendFormat:@"\t\t\t<TR><TD COLSPAN=\"3\" PORT=\"%@\">%@:<FONT FACE=\"Helvetica-Oblique\" POINT-SIZE=\"10\">%@</FONT></TD></TR>\n", [item objectForKey:@"name"], [item objectForKey:@"name"], [item objectForKey:@"type"]];
}
[metaString appendString:@"\t\t\t</TABLE>>\n"];
@@ -153,7 +153,8 @@
// see about relations
columnInfo = [tableInfo objectForKey:@"constraints"];
- for (NSInteger j = 0; j < [columnInfo count]; j++)
+ NSString *ccol = NSArrayObjectAtIndex(columnInfo, 0);
+ for (NSDictionary* item in columnInfo)
{
// Check for cancellation flag
if ([self isCancelled]) {
@@ -165,9 +166,8 @@
// Get the column references. Currently the columns themselves are an array,
// while reference columns and tables are comma separated if there are more than
// one. Only use the first of each for the time being.
- NSArray *ccols = [NSArrayObjectAtIndex(columnInfo, j) objectForKey:@"columns"];
- NSString *ccol = NSArrayObjectAtIndex(columnInfo, 0);
- NSString *rcol = [NSArrayObjectAtIndex(columnInfo, j) objectForKey:@"ref_columns"];
+ NSArray *ccols = [item objectForKey:@"columns"];
+ NSString *rcol = [item objectForKey:@"ref_columns"];
NSString *extra = @"";
@@ -176,7 +176,7 @@
rcol = NSArrayObjectAtIndex([rcol componentsSeparatedByString:@","], 0);
}
- [fkInfo addObject:[NSString stringWithFormat:@"%@:%@ -> %@:%@ %@", tableName, ccol, [NSArrayObjectAtIndex(columnInfo, j) objectForKey:@"ref_table"], rcol, extra]];
+ [fkInfo addObject:[NSString stringWithFormat:@"%@:%@ -> %@:%@ %@", tableName, ccol, [item objectForKey:@"ref_table"], rcol, extra]];
}
}
@@ -186,10 +186,8 @@
[metaString setString:@"edge [ arrowhead=inv, arrowtail=normal, style=dashed, color=\"#444444\" ];\n"];
// Get the relations
- for (NSInteger i = 0; i < [fkInfo count]; i++)
- {
- [metaString appendString:[NSString stringWithFormat:@"%@;\n", [fkInfo objectAtIndex:i]]];
- }
+ for (id item in fkInfo)
+ [metaString appendFormat:@"%@;\n", item];
[fkInfo release];
diff --git a/Source/SPExportFileUtilities.m b/Source/SPExportFileUtilities.m
index 76650556..74e992e4 100644
--- a/Source/SPExportFileUtilities.m
+++ b/Source/SPExportFileUtilities.m
@@ -80,15 +80,15 @@
[header setString:@"<?xml version=\"1.0\"?>\n\n"];
[header appendString:@"<!--\n-\n"];
[header appendString:@"- Sequel Pro XML dump\n"];
- [header appendString:[NSString stringWithFormat:@"- Version %@\n-\n", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]]];
- [header appendString:[NSString stringWithFormat:@"- %@\n- %@\n-\n", SPLOCALIZEDURL_HOMEPAGE, SPDevURL]];
- [header appendString:[NSString stringWithFormat:@"- Host: %@ (MySQL %@)\n", [tableDocumentInstance host], [tableDocumentInstance mySQLVersion]]];
- [header appendString:[NSString stringWithFormat:@"- Database: %@\n", [tableDocumentInstance database]]];
- [header appendString:[NSString stringWithFormat:@"- Generation Time: %@\n", [NSDate date]]];
+ [header appendFormat:@"- Version %@\n-\n", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
+ [header appendFormat:@"- %@\n- %@\n-\n", SPLOCALIZEDURL_HOMEPAGE, SPDevURL];
+ [header appendFormat:@"- Host: %@ (MySQL %@)\n", [tableDocumentInstance host], [tableDocumentInstance mySQLVersion]];
+ [header appendFormat:@"- Database: %@\n", [tableDocumentInstance database]];
+ [header appendFormat:@"- Generation Time: %@\n", [NSDate date]];
[header appendString:@"-\n-->\n\n"];
if (exportSource == SPTableExport) {
- [header appendString:[NSString stringWithFormat:@"<%@>\n\n", [[tableDocumentInstance database] HTMLEscapeString]]];
+ [header appendFormat:@"<%@>\n\n", [[tableDocumentInstance database] HTMLEscapeString]];
}
[file writeData:[header dataUsingEncoding:NSUTF8StringEncoding]];
diff --git a/Source/SPLogger.m b/Source/SPLogger.m
index 83c5b49c..124b19f0 100644
--- a/Source/SPLogger.m
+++ b/Source/SPLogger.m
@@ -240,7 +240,7 @@ int isSPLeaksLog(struct direct *entry)
NSString *bundleName = [fileManager displayNameAtPath:[[NSBundle mainBundle] bundlePath]];
NSMutableString *logStart = [NSMutableString stringWithString:@"\n\n\n==========================================================================\n\n"];
- [logStart appendString:[NSString stringWithFormat:@"%@ (r%ld)\n", bundleName, (long)[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] integerValue]]];
+ [logStart appendFormat:@"%@ (r%ld)\n", bundleName, (long)[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] integerValue]];
[logFileHandle writeData:[logStart dataUsingEncoding:NSUTF8StringEncoding]];
}
}
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index c34bce52..487b8284 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -635,11 +635,11 @@
c = [[self filterString] characterAtIndex:i];
if(c != '`') {
if(c == '.')
- [fuzzyRegexp appendString:[NSString stringWithFormat:@".*?%@",SPUniqueSchemaDelimiter]];
+ [fuzzyRegexp appendFormat:@".*?%@",SPUniqueSchemaDelimiter];
else if (c == '(' || c == ')' || c == '[' || c == ']' || c == '{' || c == '}')
- [fuzzyRegexp appendString:[NSString stringWithFormat:@".*?\\%c",c]];
+ [fuzzyRegexp appendFormat:@".*?\\%c",c];
else
- [fuzzyRegexp appendString:[NSString stringWithFormat:@".*?%c",c]];
+ [fuzzyRegexp appendFormat:@".*?%c",c];
}
}
diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m
index c142ed3f..7a70573e 100644
--- a/Source/SPQueryController.m
+++ b/Source/SPQueryController.m
@@ -217,24 +217,17 @@ static SPQueryController *sharedQueryController = nil;
{
if (i < [messagesVisibleSet count]) {
SPConsoleMessage *message = NSArrayObjectAtIndex(messagesVisibleSet, i);
-
+
// If the timestamp column is not hidden we need to include them in the copy
- if (!dateColumnIsHidden) {
- [string appendString:@"/* "];
- [string appendString:[dateFormatter stringFromDate:[message messageDate]]];
- if (connectionColumnIsHidden) [string appendString:@" */ "];
- else [string appendString:@" "];
- }
+ if (!dateColumnIsHidden)
+ [string appendFormat:@"/* %@ %@ ", [dateFormatter stringFromDate:[message messageDate]], (connectionColumnIsHidden) ? @"*/ ": @""];
+
// If the connection column is not hidden we need to include them in the copy
- if (!connectionColumnIsHidden) {
- if (dateColumnIsHidden) [string appendString:@"/* "];
- [string appendString:[message messageConnection]];
- [string appendString:@" */ "];
- }
-
- [string appendString:[message message]];
- [string appendString:@"\n"];
+ if (!connectionColumnIsHidden)
+ [string appendFormat:@"%@%@ */ ",(dateColumnIsHidden) ? @"/* " : @"", [message messageConnection]];
+
+ [string appendFormat:@"%@\n", [message message]];
}
i = [rows indexGreaterThanIndex:i];
@@ -916,22 +909,18 @@ static SPQueryController *sharedQueryController = nil;
if (timeStamps || connections) [consoleString appendString:@"/* "];
// If the timestamp column is not hidden we need to include them in the copy
- if (timeStamps) {
- [consoleString appendString:[dateFormatter stringFromDate:[message messageDate]]];
- [consoleString appendString:@" "];
- }
-
+ if (timeStamps)
+ [consoleString appendFormat:@"%@ ", [dateFormatter stringFromDate:[message messageDate]]];
+
// If the connection column is not hidden we need to include them in the copy
- if (connections) {
- [consoleString appendString:[message messageConnection]];
- [consoleString appendString:@" "];
- }
-
+ if (connections)
+ [consoleString appendFormat:@"%@ ", [message messageConnection]];
+
// Close the comment
if (timeStamps || connections) [consoleString appendString:@"*/ "];
- [consoleString appendString:[message message]];
- [consoleString appendString:@"\n"];
+ [consoleString appendFormat:@"%@\n", [message message]];
+
}
return consoleString;
diff --git a/Source/SPSQLExporter.m b/Source/SPSQLExporter.m
index 29385644..a38732cb 100644
--- a/Source/SPSQLExporter.m
+++ b/Source/SPSQLExporter.m
@@ -175,11 +175,11 @@
// Add the dump header to the dump file
[metaString appendString:@"# Sequel Pro SQL dump\n"];
- [metaString appendString:[NSString stringWithFormat:@"# Version %@\n#\n", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]]];
- [metaString appendString:[NSString stringWithFormat:@"# %@\n# %@\n#\n", SPLOCALIZEDURL_HOMEPAGE, SPDevURL]];
- [metaString appendString:[NSString stringWithFormat:@"# Host: %@ (MySQL %@)\n", [self sqlDatabaseHost], [self sqlDatabaseVersion]]];
- [metaString appendString:[NSString stringWithFormat:@"# Database: %@\n", [self sqlDatabaseName]]];
- [metaString appendString:[NSString stringWithFormat:@"# Generation Time: %@\n", [NSDate date]]];
+ [metaString appendFormat:@"# Version %@\n#\n", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
+ [metaString appendFormat:@"# %@\n# %@\n#\n", SPLOCALIZEDURL_HOMEPAGE, SPDevURL];
+ [metaString appendFormat:@"# Host: %@ (MySQL %@)\n", [self sqlDatabaseHost], [self sqlDatabaseVersion]];
+ [metaString appendFormat:@"# Database: %@\n", [self sqlDatabaseName]];
+ [metaString appendFormat:@"# Generation Time: %@\n", [NSDate date]];
[metaString appendString:@"# ************************************************************\n\n\n"];
// Add commands to store the client encodings used when importing and set to UTF8 to preserve data
@@ -245,7 +245,7 @@
}
if ([connection queryErrored]) {
- [errors appendString:[NSString stringWithFormat:@"%@\n", [connection getLastErrorMessage]]];
+ [errors appendFormat:@"%@\n", [connection getLastErrorMessage]];
[[self exportOutputFile] writeData:[[NSString stringWithFormat:@"# Error: %@\n\n\n", [connection getLastErrorMessage]] dataUsingEncoding:NSUTF8StringEncoding]];
@@ -296,7 +296,7 @@
NSArray *rowArray = [[connection queryString:[NSString stringWithFormat:@"SELECT COUNT(1) FROM %@", [tableName backtickQuotedString]]] fetchRowAsArray];
if ([connection queryErrored] || ![rowArray count]) {
- [errors appendString:[NSString stringWithFormat:@"%@\n", [connection getLastErrorMessage]]];
+ [errors appendFormat:@"%@\n", [connection getLastErrorMessage]];
[[self exportOutputFileHandle] writeData:[[NSString stringWithFormat:@"# Error: %@\n\n\n", [connection getLastErrorMessage]] dataUsingEncoding:NSUTF8StringEncoding]];
continue;
@@ -317,8 +317,7 @@
// Lock the table for writing and disable keys if supported
[metaString setString:@""];
- [metaString appendString:[NSString stringWithFormat:@"LOCK TABLES %@ WRITE;\n", [tableName backtickQuotedString]]];
- [metaString appendString:[NSString stringWithFormat:@"/*!40000 ALTER TABLE %@ DISABLE KEYS */;\n\n", [tableName backtickQuotedString]]];
+ [metaString appendFormat:@"LOCK TABLES %@ WRITE;\n/*!40000 ALTER TABLE %@ DISABLE KEYS */;\n\n", [tableName backtickQuotedString], [tableName backtickQuotedString]];
[[self exportOutputFile] writeData:[metaString dataUsingEncoding:[self exportOutputEncoding]]];
@@ -380,16 +379,13 @@
}
// If the field is off type BIT, the values need a binary prefix of b'x'.
else if ([[NSArrayObjectAtIndex([tableDetails objectForKey:@"columns"], t) objectForKey:@"type"] isEqualToString:@"BIT"]) {
- [sqlString appendString:@"b'"];
- [sqlString appendString:[object description]];
- [sqlString appendString:@"'"];
+ [sqlString appendFormat:@"b'%@'", [object description]];
}
// Add data types directly as hex data
else if ([object isKindOfClass:[NSData class]]) {
if ([self sqlOutputEncodeBLOBasHex]) {
- [sqlString appendString:@"X'"];
- [sqlString appendString:[connection prepareBinaryData:object]];
+ [sqlString appendFormat:@"X'%@", [connection prepareBinaryData:object]];
}
else {
[sqlString appendString:@"'"];
@@ -469,8 +465,7 @@
// Unlock the table and re-enable keys if supported
[metaString setString:@""];
- [metaString appendString:[NSString stringWithFormat:@"/*!40000 ALTER TABLE %@ ENABLE KEYS */;\n", [tableName backtickQuotedString]]];
- [metaString appendString:@"UNLOCK TABLES;\n"];
+ [metaString appendFormat:@"/*!40000 ALTER TABLE %@ ENABLE KEYS */;\nUNLOCK TABLES;\n", [tableName backtickQuotedString]];
[[self exportOutputFile] writeData:[metaString dataUsingEncoding:NSUTF8StringEncoding]];
@@ -479,7 +474,7 @@
}
if ([connection queryErrored]) {
- [errors appendString:[NSString stringWithFormat:@"%@\n", [connection getLastErrorMessage]]];
+ [errors appendFormat:@"%@\n", [connection getLastErrorMessage]];
if ([self sqlOutputIncludeErrors]) {
[[self exportOutputFile] writeData:[[NSString stringWithFormat:@"# Error: %@\n", [connection getLastErrorMessage]]
@@ -513,33 +508,27 @@
// Definer is user@host but we need to escape it to `user`@`host`
NSArray *triggersDefiner = [[triggers objectForKey:@"Definer"] componentsSeparatedByString:@"@"];
- NSString *escapedDefiner = [NSString stringWithFormat:@"%@@%@",
- [NSArrayObjectAtIndex(triggersDefiner, 0) backtickQuotedString],
- [NSArrayObjectAtIndex(triggersDefiner, 1) backtickQuotedString]
- ];
-
- [metaString appendString:[NSString stringWithFormat:@"/*!50003 SET SESSION SQL_MODE=\"%@\" */;;\n", [triggers objectForKey:@"sql_mode"]]];
- [metaString appendString:@"/*!50003 CREATE */ "];
- [metaString appendString:[NSString stringWithFormat:@"/*!50017 DEFINER=%@ */ ", escapedDefiner]];
- [metaString appendString:[NSString stringWithFormat:@"/*!50003 TRIGGER %@ %@ %@ ON %@ FOR EACH ROW %@ */;;\n",
+ [metaString appendFormat:@"/*!50003 SET SESSION SQL_MODE=\"%@\" */;;\n/*!50003 CREATE */ ", [triggers objectForKey:@"sql_mode"]];
+ [metaString appendFormat:@"/*!50017 DEFINER=%@@%@ */ /*!50003 TRIGGER %@ %@ %@ ON %@ FOR EACH ROW %@ */;;\n",
+ [NSArrayObjectAtIndex(triggersDefiner, 0) backtickQuotedString],
+ [NSArrayObjectAtIndex(triggersDefiner, 1) backtickQuotedString],
[[triggers objectForKey:@"Trigger"] backtickQuotedString],
[triggers objectForKey:@"Timing"],
[triggers objectForKey:@"Event"],
[[triggers objectForKey:@"Table"] backtickQuotedString],
[triggers objectForKey:@"Statement"]
- ]];
+ ];
[triggers release];
}
- [metaString appendString:@"DELIMITER ;\n"];
- [metaString appendString:@"/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;\n"];
+ [metaString appendString:@"DELIMITER ;\n/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;\n"];
[[self exportOutputFile] writeData:[metaString dataUsingEncoding:NSUTF8StringEncoding]];
}
if ([connection queryErrored]) {
- [errors appendString:[NSString stringWithFormat:@"%@\n", [connection getLastErrorMessage]]];
+ [errors appendFormat:@"%@\n", [connection getLastErrorMessage]];
if ([self sqlOutputIncludeErrors]) {
[[self exportOutputFile] writeData:[[NSString stringWithFormat:@"# Error: %@\n", [connection getLastErrorMessage]]
@@ -595,12 +584,9 @@
if ([queryResult numOfRows]) {
[metaString setString:@"\n"];
- [metaString appendString:@"--\n"];
- [metaString appendString:[NSString stringWithFormat:@"-- Dumping routines (%@) for database %@\n", procedureType,
- [[self sqlDatabaseName] tickQuotedString]]];
+ [metaString appendFormat:@"--\n-- Dumping routines (%@) for database %@\n--\nDELIMITER ;;\n\n", procedureType,
+ [[self sqlDatabaseName] tickQuotedString]];
- [metaString appendString:@"--\n"];
- [metaString appendString:@"DELIMITER ;;\n\n"];
// Loop through the definitions, exporting if enabled
for (s = 0; s < [queryResult numOfRows]; s++)
@@ -643,8 +629,8 @@
// Add the 'DROP' command if required
if (sqlOutputIncludeDropSyntax) {
- [metaString appendString:[NSString stringWithFormat:@"/*!50003 DROP %@ IF EXISTS %@ */;;\n", procedureType,
- [procedureName backtickQuotedString]]];
+ [metaString appendFormat:@"/*!50003 DROP %@ IF EXISTS %@ */;;\n", procedureType,
+ [procedureName backtickQuotedString]];
}
// Only continue if the 'CREATE SYNTAX' is required
@@ -665,7 +651,7 @@
[procedureName backtickQuotedString]]];
[createProcedureResult setReturnDataAsStrings:YES];
if ([connection queryErrored]) {
- [errors appendString:[NSString stringWithFormat:@"%@\n", [connection getLastErrorMessage]]];
+ [errors appendFormat:@"%@\n", [connection getLastErrorMessage]];
if ([self sqlOutputIncludeErrors]) {
[[self exportOutputFile] writeData:[[NSString stringWithFormat:@"# Error: %@\n", [connection getLastErrorMessage]] dataUsingEncoding:NSUTF8StringEncoding]];
@@ -676,7 +662,7 @@
NSDictionary *procedureInfo = [[NSDictionary alloc] initWithDictionary:[createProcedureResult fetchRowAsDictionary]];
- [metaString appendString:[NSString stringWithFormat:@"/*!50003 SET SESSION SQL_MODE=\"%@\"*/;;\n", [procedureInfo objectForKey:@"sql_mode"]]];
+ [metaString appendFormat:@"/*!50003 SET SESSION SQL_MODE=\"%@\"*/;;\n", [procedureInfo objectForKey:@"sql_mode"]];
NSString *createProcedure = [procedureInfo objectForKey:[NSString stringWithFormat:@"Create %@", [procedureType capitalizedString]]];
@@ -701,12 +687,11 @@
// END */;;
//
// Build the CREATE PROCEDURE string to include MySQL Version limiters
- [metaString appendString:[NSString stringWithFormat:@"/*!50003 CREATE*/ /*!50020 DEFINER=%@*/ /*!50003 %@ */;;\n\n", escapedDefiner, procedureBody]];
+ [metaString appendFormat:@"/*!50003 CREATE*/ /*!50020 DEFINER=%@*/ /*!50003 %@ */;;\n\n/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;;\n", escapedDefiner, procedureBody];
[procedureInfo release];
[proceduresList release];
- [metaString appendString:@"/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;;\n"];
}
[metaString appendString:@"DELIMITER ;\n"];
@@ -715,7 +700,7 @@
}
if ([connection queryErrored]) {
- [errors appendString:[NSString stringWithFormat:@"%@\n", [connection getLastErrorMessage]]];
+ [errors appendFormat:@"%@\n", [connection getLastErrorMessage]];
if ([self sqlOutputIncludeErrors]) {
[[self exportOutputFile] writeData:[[NSString stringWithFormat:@"# Error: %@\n", [connection getLastErrorMessage]] dataUsingEncoding:NSUTF8StringEncoding]];
diff --git a/Source/SPServerVariablesController.m b/Source/SPServerVariablesController.m
index a971d855..31a29477 100644
--- a/Source/SPServerVariablesController.m
+++ b/Source/SPServerVariablesController.m
@@ -169,7 +169,7 @@
for (NSDictionary *variable in variablesFiltered)
{
- [variablesString appendString:[NSString stringWithFormat:@"%@ = %@\n", [variable objectForKey:@"Variable_name"], [variable objectForKey:@"Value"]]];
+ [variablesString appendFormat:@"%@ = %@\n", [variable objectForKey:@"Variable_name"], [variable objectForKey:@"Value"]];
}
[variablesString writeToFile:[panel filename] atomically:YES encoding:NSUTF8StringEncoding error:NULL];
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index 3f078b88..f18cf96c 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -1668,9 +1668,9 @@
id keyValue = [tableValues cellDataAtRow:index column:[[[tableDataInstance columnWithName:NSArrayObjectAtIndex(primaryKeyFieldNames,0)] objectForKey:@"datacolumnindex"] integerValue]];
if([keyValue isKindOfClass:[NSData class]])
- [deleteQuery appendString:[NSString stringWithFormat:@"X'%@'", [mySQLConnection prepareBinaryData:keyValue]]];
+ [deleteQuery appendFormat:@"X'%@'", [mySQLConnection prepareBinaryData:keyValue]];
else
- [deleteQuery appendString:[NSString stringWithFormat:@"'%@'", [keyValue description]]];
+ [deleteQuery appendFormat:@"'%@'", [keyValue description]];
// Split deletion query into 256k chunks
if([deleteQuery length] > 256000) {
@@ -2251,10 +2251,10 @@
if (firstCellOutput) [queryString appendString:@", "];
else firstCellOutput = YES;
- [queryString appendString:[NSString stringWithFormat:@"%@ = %@",
- [[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"name"] backtickQuotedString], [fieldValues objectAtIndex:i]]];
+ [queryString appendFormat:@"%@ = %@",
+ [[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"name"] backtickQuotedString], [fieldValues objectAtIndex:i]];
}
- [queryString appendString:[NSString stringWithFormat:@" WHERE %@", [self argumentForRow:-2]]];
+ [queryString appendFormat:@" WHERE %@", [self argumentForRow:-2]];
}
// If UTF-8 via Latin1 view encoding is set convert the queryString into Latin1 and
@@ -2461,13 +2461,13 @@
}
if ([tempValue isNSNull]) {
- [argument appendString:[NSString stringWithFormat:@"%@ IS NULL", [NSArrayObjectAtIndex(keys, i) backtickQuotedString]]];
+ [argument appendFormat:@"%@ IS NULL", [NSArrayObjectAtIndex(keys, i) backtickQuotedString]];
}
else if ([tempValue isSPNotLoaded]) {
NSLog(@"Exceptional case: SPNotLoaded object found for method “argumentForRow:”!");
return @"";
}
- else {
+ else {
// If the field is of type BIT then it needs a binary prefix
if ([[[tableDataInstance columnWithName:NSArrayObjectAtIndex(keys, i)] objectForKey:@"type"] isEqualToString:@"BIT"]) {
[value setString:[NSString stringWithFormat:@"b'%@'", [mySQLConnection prepareString:tempValue]]];
@@ -2478,7 +2478,7 @@
else
[value setString:[NSString stringWithFormat:@"'%@'", [mySQLConnection prepareString:tempValue]]];
- [argument appendString:[NSString stringWithFormat:@"%@ = %@", [NSArrayObjectAtIndex(keys, i) backtickQuotedString], value]];
+ [argument appendFormat:@"%@ = %@", [NSArrayObjectAtIndex(keys, i) backtickQuotedString], value];
}
}
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index 0c51f083..ac490b82 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -784,11 +784,11 @@ closes the keySheet
// If the field is of type BIT, permit the use of single qoutes and also don't quote the default value.
// For example, use DEFAULT b'1' as opposed to DEFAULT 'b\'1\'' which results in an error.
else if ([[theRow objectForKey:@"Type"] isEqualToString:@"bit"]) {
- [queryString appendString:[NSString stringWithFormat:@" DEFAULT %@ ", [theRow objectForKey:@"Default"]]];
+ [queryString appendFormat:@" DEFAULT %@ ", [theRow objectForKey:@"Default"]];
}
// Otherwise, use the provided default
else {
- [queryString appendString:[NSString stringWithFormat:@" DEFAULT '%@' ", [mySQLConnection prepareString:[theRow objectForKey:@"Default"]]]];
+ [queryString appendFormat:@" DEFAULT '%@' ", [mySQLConnection prepareString:[theRow objectForKey:@"Default"]]];
}
}
@@ -809,7 +809,7 @@ closes the keySheet
// Any column comments
if ([originalColumnDetails objectForKey:@"comment"] && [(NSString *)[originalColumnDetails objectForKey:@"comment"] length]) {
- [queryString appendString:[NSString stringWithFormat:@" COMMENT '%@'", [mySQLConnection prepareString:[originalColumnDetails objectForKey:@"comment"]]]];
+ [queryString appendFormat:@" COMMENT '%@'", [mySQLConnection prepareString:[originalColumnDetails objectForKey:@"comment"]]];
}
// Unparsed details - column formats, storage, reference definitions
@@ -842,22 +842,22 @@ closes the keySheet
// Add AFTER ... only if the user added a new field
if (isEditingNewRow) {
- [queryString appendString:[NSString stringWithFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]]];
+ [queryString appendFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]];
}
}
else {
// Add AFTER ... only if the user added a new field
if (isEditingNewRow) {
- [queryString appendString:[NSString stringWithFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]]];
+ [queryString appendFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]];
}
- [queryString appendString:[NSString stringWithFormat:@", ADD %@ (%@)", [chooseKeyButton titleOfSelectedItem], [[theRow objectForKey:@"Field"] backtickQuotedString]]];
+ [queryString appendFormat:@", ADD %@ (%@)", [chooseKeyButton titleOfSelectedItem], [[theRow objectForKey:@"Field"] backtickQuotedString]];
}
}
}
// Add AFTER ... only if the user added a new field
else if (isEditingNewRow) {
- [queryString appendString:[NSString stringWithFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]]];
+ [queryString appendFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]];
}
// Execute query
@@ -1344,7 +1344,7 @@ would result in a position change.
// Add the length parameter if necessary
if ( [originalRow objectForKey:@"Length"] && ![[originalRow objectForKey:@"Length"] isEqualToString:@""]) {
- [queryString appendString:[NSString stringWithFormat:@"(%@)", [originalRow objectForKey:@"Length"]]];
+ [queryString appendFormat:@"(%@)", [originalRow objectForKey:@"Length"]];
}
// Add unsigned, zerofill, binary, not null if necessary
@@ -1377,7 +1377,7 @@ would result in a position change.
[queryString appendString:@" DEFAULT CURRENT_TIMESTAMP"];
}
else {
- [queryString appendString:[NSString stringWithFormat:@" DEFAULT '%@'", [mySQLConnection prepareString:[originalRow objectForKey:@"Default"]]]];
+ [queryString appendFormat:@" DEFAULT '%@'", [mySQLConnection prepareString:[originalRow objectForKey:@"Default"]]];
}
// Add details not provided via the SHOW COLUMNS query from the table data cache so column details aren't lost
@@ -1385,7 +1385,7 @@ would result in a position change.
// Any column comments
if ([originalColumnDetails objectForKey:@"comment"] && [(NSString *)[originalColumnDetails objectForKey:@"comment"] length]) {
- [queryString appendString:[NSString stringWithFormat:@" COMMENT '%@'", [mySQLConnection prepareString:[originalColumnDetails objectForKey:@"comment"]]]];
+ [queryString appendFormat:@" COMMENT '%@'", [mySQLConnection prepareString:[originalColumnDetails objectForKey:@"comment"]]];
}
// Unparsed details - column formats, storage, reference definitions
@@ -1397,8 +1397,8 @@ would result in a position change.
if ( destinationRowIndex == 0 ){
[queryString appendString:@" FIRST"];
} else {
- [queryString appendString:[NSString stringWithFormat:@" AFTER %@",
- [[[tableFields objectAtIndex:destinationRowIndex-1] objectForKey:@"Field"] backtickQuotedString]]];
+ [queryString appendFormat:@" AFTER %@",
+ [[[tableFields objectAtIndex:destinationRowIndex-1] objectForKey:@"Field"] backtickQuotedString]];
}
// Run the query; report any errors, or reload the table on success
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index 8bd1f687..5f692c68 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -997,21 +997,21 @@
for (NSManagedObject *user in deletedUsers)
{
- if (![[[user entity] name] isEqualToString:@"Privileges"] && [user valueForKey:@"host"] != nil)
+ if (![[[user entity] name] isEqualToString:@"Privileges"] && [user valueForKey:@"host"] != nil)
{
- [droppedUsers appendString:[NSString stringWithFormat:@"%@@%@, ",
- [[user valueForKey:@"user"] tickQuotedString],
- [[user valueForKey:@"host"] tickQuotedString]]];
+ [droppedUsers appendFormat:@"%@@%@, ",
+ [[user valueForKey:@"user"] tickQuotedString],
+ [[user valueForKey:@"host"] tickQuotedString]];
}
-
+
+ }
+
+ if ([droppedUsers length] > 2) {
+ droppedUsers = [[droppedUsers substringToIndex:[droppedUsers length]-2] mutableCopy];
+ [self.mySqlConnection queryString:[NSString stringWithFormat:@"DROP USER %@", droppedUsers]];
+ [droppedUsers release];
}
- if ([droppedUsers length] > 2) {
- droppedUsers = [[droppedUsers substringToIndex:[droppedUsers length]-2] mutableCopy];
- [self.mySqlConnection queryString:[NSString stringWithFormat:@"DROP USER %@", droppedUsers]];
- [droppedUsers release];
- }
-
return TRUE;
}