diff options
author | rowanbeentje <rowan@beent.je> | 2009-06-24 23:52:47 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-06-24 23:52:47 +0000 |
commit | c118f1a8166d1c612bed66ab64235cab6111a3cd (patch) | |
tree | 2a4e12d348f0c5f67d69d7974ae3481cbe24737a | |
parent | 15981eb3fbf5438de932c7b815707f3c6a7f0110 (diff) | |
download | sequelpro-c118f1a8166d1c612bed66ab64235cab6111a3cd.tar.gz sequelpro-c118f1a8166d1c612bed66ab64235cab6111a3cd.tar.bz2 sequelpro-c118f1a8166d1c612bed66ab64235cab6111a3cd.zip |
- Make changes to the table structure flush the appropriate table data caches
- SPTableData's columnWithName: now updates caches as necessary to avoid issues
- Mark the extended table info view (particularly the CREATE TABLE syntax) as requiring update following table structure changes
-rw-r--r-- | Source/SPTableData.m | 7 | ||||
-rw-r--r-- | Source/TableSource.m | 26 | ||||
-rw-r--r-- | Source/TablesList.h | 1 | ||||
-rw-r--r-- | Source/TablesList.m | 8 |
4 files changed, 34 insertions, 8 deletions
diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 0358e984..e348ac79 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -122,6 +122,13 @@ */ - (NSDictionary *) columnWithName:(NSString *)colName { + if ([columns count] == 0) { + if ([tableListInstance tableType] == SP_TABLETYPE_VIEW) { + [self updateInformationForCurrentView]; + } else { + [self updateInformationForCurrentTable]; + } + } int columnIndex = [columnNames indexOfObject:colName]; if (columnIndex == NSNotFound) return nil; return [columns objectAtIndex:columnIndex]; diff --git a/Source/TableSource.m b/Source/TableSource.m index bd48b2ce..04441018 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -246,6 +246,8 @@ reloads the table (performing a new mysql-query) */ - (IBAction)reloadTable:(id)sender { + [tableDataInstance resetColumnData]; + [tablesListInstance setStatusRequiresReload:YES]; [self loadTable:selectedTable]; } @@ -346,6 +348,8 @@ reloads the table (performing a new mysql-query) [tempIndexedColumns componentsJoinedAndBacktickQuoted]]]; if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { + [tableDataInstance resetColumnData]; + [tablesListInstance setStatusRequiresReload:YES]; [self loadTable:selectedTable]; [NSApp stopModalWithCode:1]; } else { @@ -784,11 +788,12 @@ fetches the result as an array with a dictionary for each row in it isEditingNewRow = NO; currentlyEditingRow = -1; + [tableDataInstance resetColumnData]; + [tablesListInstance setStatusRequiresReload:YES]; [self loadTable:selectedTable]; - // Mark the content table and column caches for refresh + // Mark the content table for refresh [tablesListInstance setContentRequiresReload:YES]; - [tableDataInstance resetColumnData]; return YES; } @@ -851,11 +856,12 @@ fetches the result as an array with a dictionary for each row in it [selectedTable backtickQuotedString], [[[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"Field"] backtickQuotedString]]]; if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { + [tableDataInstance resetColumnData]; + [tablesListInstance setStatusRequiresReload:YES]; [self loadTable:selectedTable]; - // Mark the content table and column cache for refresh + // Mark the content table cache for refresh [tablesListInstance setContentRequiresReload:YES]; - [tableDataInstance resetColumnData]; } else { [self performSelector:@selector(showErrorSheetWith:) withObject:[NSArray arrayWithObjects:NSLocalizedString(@"Error", @"error"), @@ -877,6 +883,8 @@ fetches the result as an array with a dictionary for each row in it } if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { + [tableDataInstance resetColumnData]; + [tablesListInstance setStatusRequiresReload:YES]; [self loadTable:selectedTable]; } else { [self performSelector:@selector(showErrorSheetWith:) @@ -1158,7 +1166,13 @@ would result in a position change. NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't move field. MySQL said: %@", @"message of panel when field cannot be added in drag&drop operation"), [mySQLConnection getLastErrorMessage]]); } else { + [tableDataInstance resetColumnData]; + [tablesListInstance setStatusRequiresReload:YES]; [self loadTable:selectedTable]; + + // Mark the content table cache for refresh + [tablesListInstance setContentRequiresReload:YES]; + if ( originalRowIndex < destinationRowIndex ) { [tableSourceView selectRow:destinationRowIndex-1 byExtendingSelection:NO]; } else { @@ -1167,10 +1181,6 @@ would result in a position change. } [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; - - // Mark the content table and column caches for refresh - [tablesListInstance setContentRequiresReload:YES]; - [tableDataInstance resetColumnData]; [originalRow release]; return YES; diff --git a/Source/TablesList.h b/Source/TablesList.h index 0c2848ef..032f7f15 100644 --- a/Source/TablesList.h +++ b/Source/TablesList.h @@ -115,5 +115,6 @@ enum sp_table_types // Setters - (void)setContentRequiresReload:(BOOL)reload; +- (void)setStatusRequiresReload:(BOOL)reload; @end diff --git a/Source/TablesList.m b/Source/TablesList.m index b4f8b7c2..d07fe544 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -960,6 +960,14 @@ contentLoaded = !reload; } +/** + * Mark the exteded table info for refresh when it's next switched to + */ +- (void)setStatusRequiresReload:(BOOL)reload +{ + statusLoaded = !reload; +} + #pragma mark Datasource methods /** |