diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-07-14 19:34:40 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-07-14 19:34:40 +0000 |
commit | 0612652448f32e620a96e923a44b463fa1b9e0dc (patch) | |
tree | c77ff4cd7596aed10e445d0051620ecfbe295f7e /Source/TablesList.m | |
parent | 6686223d2c30a7b99b8de11a8659851725f6326f (diff) | |
download | sequelpro-0612652448f32e620a96e923a44b463fa1b9e0dc.tar.gz sequelpro-0612652448f32e620a96e923a44b463fa1b9e0dc.tar.bz2 sequelpro-0612652448f32e620a96e923a44b463fa1b9e0dc.zip |
• fix for completion in CustomQuery editor
- now the gathering of suggestions does not query the MySQL connection, instead it uses the TableList/TableDocument tableView data as a kind of cache
- this approach should improve the speed for slow server connections
TODO: auto-update for TableList and Database List resp. (it could happen that an other user changed the name of a table/db meanwhile)
Diffstat (limited to 'Source/TablesList.m')
-rw-r--r-- | Source/TablesList.m | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Source/TablesList.m b/Source/TablesList.m index ec330d9a..49b97008 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -930,6 +930,78 @@ } /** + * Database tables accessors for a given table type + */ +- (NSArray *)allTableAndViewNames +{ + NSMutableArray *returnArray = [NSMutableArray array]; + int i; + int cnt = [[self tables] count]; + for(i=0; i<cnt; i++) { + if([NSArrayObjectAtIndex([self tableTypes],i) intValue] == SP_TABLETYPE_TABLE || [NSArrayObjectAtIndex([self tableTypes],i) intValue] == SP_TABLETYPE_VIEW) + [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; + } + [returnArray sortUsingSelector:@selector(compare:)]; + return returnArray; +} +- (NSArray *)allTableNames +{ + NSMutableArray *returnArray = [NSMutableArray array]; + int i; + int cnt = [[self tables] count]; + for(i=0; i<cnt; i++) { + if([NSArrayObjectAtIndex([self tableTypes],i) intValue] == SP_TABLETYPE_TABLE) + [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; + } + [returnArray sortUsingSelector:@selector(compare:)]; + return returnArray; +} +- (NSArray *)allViewNames +{ + NSMutableArray *returnArray = [NSMutableArray array]; + int i; + int cnt = [[self tables] count]; + for(i=0; i<cnt; i++) { + if([NSArrayObjectAtIndex([self tableTypes],i) intValue] == SP_TABLETYPE_VIEW) + [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; + } + [returnArray sortUsingSelector:@selector(compare:)]; + return returnArray; +} +- (NSArray *)allProcedureNames +{ + NSMutableArray *returnArray = [NSMutableArray array]; + int i; + int cnt = [[self tables] count]; + for(i=0; i<cnt; i++) { + if([NSArrayObjectAtIndex([self tableTypes],i) intValue] == SP_TABLETYPE_PROC) + [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; + } + [returnArray sortUsingSelector:@selector(compare:)]; + return returnArray; +} +- (NSArray *)allFunctionNames +{ + NSMutableArray *returnArray = [NSMutableArray array]; + int i; + int cnt = [[self tables] count]; + for(i=0; i<cnt; i++) { + if([NSArrayObjectAtIndex([self tableTypes],i) intValue] == SP_TABLETYPE_FUNC) + [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; + } + [returnArray sortUsingSelector:@selector(compare:)]; + return returnArray; +} + +/** + * Returns an array of all available database names + */ +- (NSArray *)allDatabaseNames +{ + return [tableDocumentInstance allDatabaseNames]; +} + +/** * Database table types accessor */ - (NSArray *)tableTypes |