aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-06-16 15:22:49 +0000
committerBibiko <bibiko@eva.mpg.de>2009-06-16 15:22:49 +0000
commit6333eb96026649557a66d23efbf3746fd285307e (patch)
tree601c989273757ac97481e1794b1f5692a24972a7
parente7c321f9af247b84eb566c35e6763324cf36b49b (diff)
downloadsequelpro-6333eb96026649557a66d23efbf3746fd285307e.tar.gz
sequelpro-6333eb96026649557a66d23efbf3746fd285307e.tar.bz2
sequelpro-6333eb96026649557a66d23efbf3746fd285307e.zip
• fixed: if the user tries to delete the last defined field in a given table show an alert saying that this isn't allowed
-rw-r--r--Source/TableSource.m18
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/TableSource.m b/Source/TableSource.m
index 8ed241b8..6509fa24 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -348,6 +348,21 @@ reloads the table (performing a new mysql-query)
if (![self saveRowOnDeselect])
return;
+ // Check if the user tries to delete the last defined field in table
+ if ([tableSourceView numberOfRows] < 2) {
+ NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while deleting field", @"Error while deleting field")
+ defaultButton:NSLocalizedString(@"OK", @"OK button")
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:NSLocalizedString(@"You cannot delete the last field in a table. Use “Remove table” (DROP TABLE) instead.",
+ @"You cannot delete the last field in that table. Use “Remove table” (DROP TABLE) instead")];
+
+ [alert setAlertStyle:NSCriticalAlertStyle];
+
+ [alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"cannotremovefield"];
+
+ }
+
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Delete field?", @"delete field message")
defaultButton:NSLocalizedString(@"Delete", @"delete button")
alternateButton:NSLocalizedString(@"Cancel", @"cancel button")
@@ -796,7 +811,10 @@ fetches the result as an array with a dictionary for each row in it
[NSString stringWithFormat:NSLocalizedString(@"Couldn't remove index.\nMySQL said: %@", @"message of panel when index cannot be removed"), [mySQLConnection getLastErrorMessage]]);
}
}
+ } else if ( [contextInfo isEqualToString:@"cannotremovefield"]) {
+ ;
}
+
}
/**