diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-06-16 15:22:49 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-06-16 15:22:49 +0000 |
commit | 6333eb96026649557a66d23efbf3746fd285307e (patch) | |
tree | 601c989273757ac97481e1794b1f5692a24972a7 /Source/TableSource.m | |
parent | e7c321f9af247b84eb566c35e6763324cf36b49b (diff) | |
download | sequelpro-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
Diffstat (limited to 'Source/TableSource.m')
-rw-r--r-- | Source/TableSource.m | 18 |
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"]) { + ; } + } /** |