diff options
author | rowanbeentje <rowan@beent.je> | 2010-09-05 22:25:47 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-09-05 22:25:47 +0000 |
commit | a284c331debb4d9c170fe02c3eff435dd6b7e94d (patch) | |
tree | 1ac9da2be84fe683d34975e29c148d010715c008 | |
parent | 46344761d22504556f7fdf6321f706e33f85804f (diff) | |
download | sequelpro-a284c331debb4d9c170fe02c3eff435dd6b7e94d.tar.gz sequelpro-a284c331debb4d9c170fe02c3eff435dd6b7e94d.tar.bz2 sequelpro-a284c331debb4d9c170fe02c3eff435dd6b7e94d.zip |
- Fix incomplete argument logic when deleting multiple rows without indexes (now rolled into argumentForRow: for centralised logic), addressing Issue #791
- Update table row count at bottom of window when deleting rows in the content view
- Update localisable strings
-rw-r--r-- | Resources/English.lproj/DataMigrationDialog.strings | bin | 15340 -> 18292 bytes | |||
-rw-r--r-- | Resources/English.lproj/ImportAccessory.strings | bin | 7442 -> 7436 bytes | |||
-rw-r--r-- | Resources/English.lproj/Localizable.strings | bin | 168700 -> 169886 bytes | |||
-rw-r--r-- | Source/SPTableContent.h | 1 | ||||
-rw-r--r-- | Source/SPTableContent.m | 46 |
5 files changed, 26 insertions, 21 deletions
diff --git a/Resources/English.lproj/DataMigrationDialog.strings b/Resources/English.lproj/DataMigrationDialog.strings Binary files differindex 89aa301d..1280b4cd 100644 --- a/Resources/English.lproj/DataMigrationDialog.strings +++ b/Resources/English.lproj/DataMigrationDialog.strings diff --git a/Resources/English.lproj/ImportAccessory.strings b/Resources/English.lproj/ImportAccessory.strings Binary files differindex 88e4758a..058feae0 100644 --- a/Resources/English.lproj/ImportAccessory.strings +++ b/Resources/English.lproj/ImportAccessory.strings diff --git a/Resources/English.lproj/Localizable.strings b/Resources/English.lproj/Localizable.strings Binary files differindex e39c1a96..88766593 100644 --- a/Resources/English.lproj/Localizable.strings +++ b/Resources/English.lproj/Localizable.strings diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h index b82eb7c3..f88d6fe9 100644 --- a/Source/SPTableContent.h +++ b/Source/SPTableContent.h @@ -159,6 +159,7 @@ - (void)processResultIntoDataStorage:(MCPStreamingResult *)theResult approximateRowCount:(NSUInteger)targetRowCount; - (BOOL)addRowToDB; - (NSString *)argumentForRow:(NSInteger)row; +- (NSString *)argumentForRow:(NSInteger)row excludingLimits:(BOOL)excludeLimits; - (NSString *)argumentForRow:(NSUInteger)rowIndex ofTable:(NSString *)tableForColumn andDatabase:(NSString *)database includeBlobs:(BOOL)includeBlobs; - (BOOL)tableContainsBlobOrTextColumns; - (NSString *)fieldListForQuery; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index b57678e5..30329809 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -1626,6 +1626,10 @@ [mySQLConnection queryString:[NSString stringWithFormat:@"DELETE FROM %@", [selectedTable backtickQuotedString]]]; if ( ![mySQLConnection queryErrored] ) { + maxNumRows = 0; + tableRowsCount = 0; + maxNumRowsIsEstimate = NO; + [self updateCountText]; // Reset auto increment if suppression button was ticked if([[alert suppressionButton] state] == NSOnState) { @@ -1684,6 +1688,7 @@ } [tableContentView selectRowIndexes:[NSIndexSet indexSet] byExtendingSelection:NO]; + NSInteger affectedRows = 0; errors = 0; // Disable updating of the Console Log window for large number of queries @@ -1738,6 +1743,8 @@ if(!reloadAfterRemovingRow) [selectedRows removeIndex:index]; errors++; + } else { + affectedRows++; } } else { if(!reloadAfterRemovingRow) @@ -1750,7 +1757,6 @@ // if table has only one PRIMARY KEY // delete the fast way by using the PRIMARY KEY in an IN clause NSMutableString *deleteQuery = [NSMutableString string]; - NSInteger affectedRows = 0; [deleteQuery setString:[NSString stringWithFormat:@"DELETE FROM %@ WHERE %@ IN (", [selectedTable backtickQuotedString], [NSArrayObjectAtIndex(primaryKeyFieldNames,0) backtickQuotedString]]]; @@ -1793,7 +1799,6 @@ // if table has more than one PRIMARY KEY // delete the row by using all PRIMARY KEYs in an OR clause NSMutableString *deleteQuery = [NSMutableString string]; - NSInteger affectedRows = 0; [deleteQuery setString:[NSString stringWithFormat:@"DELETE FROM %@ WHERE ", [selectedTable backtickQuotedString]]]; @@ -1801,23 +1806,7 @@ // Build the AND clause of PRIMARY KEYS [deleteQuery appendString:@"("]; - for(NSString *primaryKeyFieldName in primaryKeyFieldNames) { - - id keyValue = [tableValues cellDataAtRow:index column:[[[tableDataInstance columnWithName:primaryKeyFieldName] objectForKey:@"datacolumnindex"] integerValue]]; - - [deleteQuery appendString:[primaryKeyFieldName backtickQuotedString]]; - if ([keyValue isKindOfClass:[NSData class]]) { - [deleteQuery appendString:@"=X'"]; - [deleteQuery appendString:[mySQLConnection prepareBinaryData:keyValue]]; - } else { - [deleteQuery appendString:@"='"]; - [deleteQuery appendString:[mySQLConnection prepareString:[keyValue description]]]; - } - [deleteQuery appendString:@"' AND "]; - } - - // Remove the trailing AND and add the closing bracket - [deleteQuery deleteCharactersInRange:NSMakeRange([deleteQuery length]-5, 5)]; + [deleteQuery appendString:[self argumentForRow:index excludingLimits:YES]]; [deleteQuery appendString:@")"]; // Split deletion query into 64k chunks @@ -1850,6 +1839,10 @@ // Restore Console Log window's updating bahaviour [[SPQueryController sharedQueryController] setAllowConsoleUpdate:consoleUpdateStatus]; + maxNumRows -= affectedRows; + tableRowsCount -= affectedRows; + [self updateCountText]; + if (errors) { NSArray *message; //TODO: The following three messages are NOT localisable! @@ -2475,13 +2468,24 @@ return NO; } -/* +/** * Returns the WHERE argument to identify a row. * If "row" is -2, it uses the oldRow. * Uses the primary key if available, otherwise uses all fields as argument and sets LIMIT to 1 */ - (NSString *)argumentForRow:(NSInteger)row { + return [self argumentForRow:row excludingLimits:NO]; +} + +/** + * Returns the WHERE argument to identify a row. + * If "row" is -2, it uses the oldRow value. + * "excludeLimits" controls whether a LIMIT 1 is appended if no primary key was available to + * uniquely identify the row. + */ +- (NSString *)argumentForRow:(NSInteger)row excludingLimits:(BOOL)excludeLimits +{ MCPResult *theResult; NSDictionary *theRow; id tempValue; @@ -2565,7 +2569,7 @@ } } - if (setLimit) [argument appendString:@" LIMIT 1"]; + if (setLimit && !excludeLimits) [argument appendString:@" LIMIT 1"]; return argument; } |