aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-05-03 12:02:20 +0000
committerstuconnolly <stuart02@gmail.com>2010-05-03 12:02:20 +0000
commitd0cfe2b688a6c483c6f89bf17df4a4e2f29e7970 (patch)
tree7c0f721773db832b4ecd17acc28507a9feefa65c
parent8acde6bf2580ce1e2feac2b9ac74dfa34b1ddf7e (diff)
downloadsequelpro-d0cfe2b688a6c483c6f89bf17df4a4e2f29e7970.tar.gz
sequelpro-d0cfe2b688a6c483c6f89bf17df4a4e2f29e7970.tar.bz2
sequelpro-d0cfe2b688a6c483c6f89bf17df4a4e2f29e7970.zip
Fix errors count calculation when removing multiple table rows. Caused by [MCPConnection affectedRows] returning -1. Fixes issue #654.
-rw-r--r--Source/TableContent.m22
1 files changed, 13 insertions, 9 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m
index bd2b3ca0..b78a6423 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -2187,7 +2187,7 @@
} else {
[self performSelector:@selector(showErrorSheetWith:)
withObject:[NSArray arrayWithObjects:NSLocalizedString(@"Error", @"error"),
- [NSString stringWithFormat:NSLocalizedString(@"Couldn't delete rows.\nMySQL said: %@", @"message when deleteing all rows failed"),
+ [NSString stringWithFormat:NSLocalizedString(@"Couldn't delete rows.\n\nMySQL said: %@", @"message when deleteing all rows failed"),
[mySQLConnection getLastErrorMessage]],
nil]
afterDelay:0.3];
@@ -2334,7 +2334,8 @@
// Remember affected rows for error checking
affectedRows += [mySQLConnection affectedRows];
}
- errors = [selectedRows count] - affectedRows;
+
+ errors = (affectedRows > 0) ? [selectedRows count] - affectedRows : [selectedRows count];
} else {
// if table has more than one PRIMARY KEY
// delete the row by using all PRIMARY KEYs in an OR clause
@@ -2389,21 +2390,23 @@
// Remember affected rows for error checking
affectedRows += [mySQLConnection affectedRows];
}
- errors = [selectedRows count] - affectedRows;
+
+ errors = (affectedRows > 0) ? [selectedRows count] - affectedRows : [selectedRows count];
}
-
+
// Restore Console Log window's updating bahaviour
[[SPQueryController sharedQueryController] setAllowConsoleUpdate:consoleUpdateStatus];
-
- if ( errors ) {
+
+ if (errors) {
NSArray *message;
//TODO: The following three messages are NOT localisable!
- if(errors < 0) {
+ if (errors < 0) {
message = [NSArray arrayWithObjects:NSLocalizedString(@"Warning", @"warning"),
[NSString stringWithFormat:NSLocalizedString(@"%ld row%@ more %@ deleted! Please check the Console and inform the Sequel Pro team!", @"message of panel when more rows were deleted"), (long)(errors*-1), ((errors*-1)>1)?@"s":@"", (errors>1)?@"were":@"was"],
nil];
- } else {
- if(primaryKeyFieldNames == nil)
+ }
+ else {
+ if (primaryKeyFieldNames == nil)
message = [NSArray arrayWithObjects:NSLocalizedString(@"Warning", @"warning"),
[NSString stringWithFormat:NSLocalizedString(@"%ld row%@ ha%@ not been deleted. Reload the table to be sure that the rows exist and use a primary key for your table.", @"message of panel when not all selected fields have been deleted"), (long)errors, (errors>1)?@"s":@"", (errors>1)?@"ve":@"s"],
nil];
@@ -2412,6 +2415,7 @@
[NSString stringWithFormat:NSLocalizedString(@"%ld row%@ ha%@ not been deleted. Reload the table to be sure that the rows exist and check the Console for possible errors inside the primary key%@ for your table.", @"message of panel when not all selected fields have been deleted by using primary keys"), (long)errors, (errors>1)?@"s":@"", (errors>1)?@"ve":@"s", (errors>1)?@"s":@""],
nil];
}
+
[self performSelector:@selector(showErrorSheetWith:)
withObject:message
afterDelay:0.3];