diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-02-03 12:46:23 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-02-03 12:46:23 +0000 |
commit | 7567724b1e66bc394bf36c7d7b153dd048018f03 (patch) | |
tree | 96b260fe3609d82f72705b7b164f8a3e64a5e41c /Source/TableSource.m | |
parent | c9e9a6a1c8d8c9d0e40a45a2ce2d5d95cf1dafba (diff) | |
download | sequelpro-7567724b1e66bc394bf36c7d7b153dd048018f03.tar.gz sequelpro-7567724b1e66bc394bf36c7d7b153dd048018f03.tar.bz2 sequelpro-7567724b1e66bc394bf36c7d7b153dd048018f03.zip |
• improved error handling in Structure View for adding/renaming/removing a field if the actual underlying table doesn't exit anymore; now it informs the user, clean the view, and reloads the Table List
• improved error handling in Content View for refreshing data for the current table if the table doesn't exist anymore
- this fix and the fix in [TableContent setCompareTypes:] to check for valid table data removes some NSPlaceholderString and NSScanner warnings
Diffstat (limited to 'Source/TableSource.m')
-rw-r--r-- | Source/TableSource.m | 28 |
1 files changed, 26 insertions, 2 deletions
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 - |