diff options
author | rowanbeentje <rowan@beent.je> | 2009-06-23 23:28:12 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-06-23 23:28:12 +0000 |
commit | fbc82502be6a75f0934a2dfe925c94ff0d30d8d2 (patch) | |
tree | 96478e099a1af6837b8bddee14bde21753c11675 /Source | |
parent | 24f0afbfe3416b7896d0a3b4f654f04944adf39d (diff) | |
download | sequelpro-fbc82502be6a75f0934a2dfe925c94ff0d30d8d2.tar.gz sequelpro-fbc82502be6a75f0934a2dfe925c94ff0d30d8d2.tar.bz2 sequelpro-fbc82502be6a75f0934a2dfe925c94ff0d30d8d2.zip |
- Tweak to table relations to allow data refreshing to optionally clear the master data cache; removes the duplicate CREATE TABLE command on table load, reducing overall queries and so improving speed further
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPTableRelations.m | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index a08639f9..757dc991 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -33,6 +33,7 @@ @interface SPTableRelations (PrivateAPI) +- (void)_refreshRelationDataForcingCacheRefresh:(BOOL)clearAllCaches; - (void)_updateAvailableTableColumns; @end @@ -170,7 +171,7 @@ [NSString stringWithFormat:NSLocalizedString(@"The specified relation was unable to be created.\n\nMySQL said: %@", @"error creating relation informative message"), [connection getLastErrorMessage]]); } else { - [self refreshRelations:nil]; + [self _refreshRelationDataForcingCacheRefresh:YES]; } } @@ -214,40 +215,17 @@ row = [selectedSet indexLessThanIndex:row]; } - [self refreshRelations:nil]; + [self _refreshRelationDataForcingCacheRefresh:YES]; } } } /** - * Refreshes the displayed relations. + * Trigger a refresh of the displayed relations via the interface. */ - (IBAction)refreshRelations:(id)sender { - [relationData removeAllObjects]; - - if ([tablesListInstance tableType] == SP_TABLETYPE_TABLE) { - - [tableDataInstance updateInformationForCurrentTable]; - - NSArray *constraints = [tableDataInstance getConstraints]; - - for (NSDictionary *constraint in constraints) - { - [relationData addObject:[NSDictionary dictionaryWithObjectsAndKeys: - [tablesListInstance tableName], @"table", - [constraint objectForKey:@"name"], @"name", - [constraint objectForKey:@"columns"], @"columns", - [constraint objectForKey:@"ref_table"], @"fk_table", - [constraint objectForKey:@"ref_columns"], @"fk_columns", - [constraint objectForKey:@"update"], @"on_update", - [constraint objectForKey:@"delete"], @"on_delete", - nil]]; - - } - } - - [relationsTableView reloadData]; + [self _refreshRelationDataForcingCacheRefresh:YES]; } /** @@ -280,7 +258,7 @@ [labelTextField setStringValue:([tablesListInstance tableType] == SP_TABLETYPE_TABLE) ? @"This table does not support relations" : @""]; } - [self refreshRelations:self]; + [self _refreshRelationDataForcingCacheRefresh:NO]; } #pragma mark - @@ -325,6 +303,37 @@ @implementation SPTableRelations (PrivateAPI) /** + * Refresh the displayed relations, optionally forcing a refresh of the underlying cache. + */ +- (void)_refreshRelationDataForcingCacheRefresh:(BOOL)clearAllCaches +{ + [relationData removeAllObjects]; + + if ([tablesListInstance tableType] == SP_TABLETYPE_TABLE) { + + if (clearAllCaches) [tableDataInstance updateInformationForCurrentTable]; + + NSArray *constraints = [tableDataInstance getConstraints]; + + for (NSDictionary *constraint in constraints) + { + [relationData addObject:[NSDictionary dictionaryWithObjectsAndKeys: + [tablesListInstance tableName], @"table", + [constraint objectForKey:@"name"], @"name", + [constraint objectForKey:@"columns"], @"columns", + [constraint objectForKey:@"ref_table"], @"fk_table", + [constraint objectForKey:@"ref_columns"], @"fk_columns", + [constraint objectForKey:@"update"], @"on_update", + [constraint objectForKey:@"delete"], @"on_delete", + nil]]; + + } + } + + [relationsTableView reloadData]; +} + +/** * Updates the available table columns that the reference is pointing to. Available columns are those that are * within the selected table and are of the same data type as the column the reference is from. */ |