aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPTableData.m4
-rw-r--r--Source/TableContent.m9
-rw-r--r--Source/TableSource.m28
3 files changed, 37 insertions, 4 deletions
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index 9dffd962..2c6136a3 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -336,6 +336,10 @@
nil, nil, [NSApp mainWindow], self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving the information for table '%@'. Please try again.\n\nMySQL said: %@", @"error retrieving table information informative message"),
tableName, [mySQLConnection getLastErrorMessage]]);
+ // If the current table doesn't exist anymore reload table list
+ if([mySQLConnection getLastErrorID] == 1146) {
+ [tableListInstance updateTables:nil];
+ }
}
return nil;
diff --git a/Source/TableContent.m b/Source/TableContent.m
index d25799d5..4cc573c4 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -1566,10 +1566,15 @@
return;
}
- NSString *fieldTypeGrouping = [NSString stringWithString:[[tableDataInstance columnWithName:[[fieldField selectedItem] title]] objectForKey:@"typegrouping"]];
[compareField removeAllItems];
-
+
+ NSString *fieldTypeGrouping;
+ if([[tableDataInstance columnWithName:[[fieldField selectedItem] title]] objectForKey:@"typegrouping"])
+ fieldTypeGrouping = [NSString stringWithString:[[tableDataInstance columnWithName:[[fieldField selectedItem] title]] objectForKey:@"typegrouping"]];
+ else
+ return;
+
if ( [fieldTypeGrouping isEqualToString:@"date"] ) {
compareType = @"date";
diff --git a/Source/TableSource.m b/Source/TableSource.m
index 819bdea7..79a7f4ae 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -820,7 +820,29 @@ fetches the result as an array with a dictionary for each row in it
}
else {
alertSheetOpened = YES;
-
+ if([mySQLConnection getLastErrorID] == 1146) { // If the current table doesn't exist anymore
+ SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"),
+ NSLocalizedString(@"OK", @"OK button"),
+ nil, nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, nil,
+ [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to alter table '%@'.\n\nMySQL said: %@", @"error while trying to alter table message"),
+ selectedTable, [mySQLConnection getLastErrorMessage]]);
+
+ isEditingRow = NO;
+ isEditingNewRow = NO;
+ currentlyEditingRow = -1;
+ [tableFields removeAllObjects];
+ [indexes removeAllObjects];
+ [tableSourceView reloadData];
+ [indexView reloadData];
+ [addFieldButton setEnabled:NO];
+ [copyFieldButton setEnabled:NO];
+ [removeFieldButton setEnabled:NO];
+ [addIndexButton setEnabled:NO];
+ [removeIndexButton setEnabled:NO];
+ [editTableButton setEnabled:NO];
+ [tablesListInstance updateTables:self];
+ return NO;
+ }
// Problem: alert sheet doesn't respond to first click
if (isEditingNewRow) {
SPBeginAlertSheet(NSLocalizedString(@"Error adding field", @"error adding field message"),
@@ -947,7 +969,7 @@ fetches the result as an array with a dictionary for each row in it
currentlyEditingRow = -1;
}
[tableSourceView reloadData];
- }
+ }
else if ([contextInfo isEqualToString:@"removeField"] || [contextInfo isEqualToString:@"removeFieldAndForeignKey"]) {
if (returnCode == NSAlertDefaultReturn) {
[self _removeFieldAndForeignKey:[contextInfo hasSuffix:@"AndForeignKey"]];
@@ -966,6 +988,8 @@ fetches the result as an array with a dictionary for each row in it
else if ([contextInfo isEqualToString:@"cannotremovefield"]) {
;
}
+ else
+ alertSheetOpened = NO;
}
#pragma mark -