aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableDocument.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-12-23 20:08:14 +0000
committerstuconnolly <stuart02@gmail.com>2009-12-23 20:08:14 +0000
commitbf7ed8561accb5a3ce2e7cb8f681017adcd8f055 (patch)
treecbd6790fc7a0003d296831184457891c61263942 /Source/TableDocument.m
parent0c06d9da2cfdd91f4e775946f89975a1d2754b6e (diff)
downloadsequelpro-bf7ed8561accb5a3ce2e7cb8f681017adcd8f055.tar.gz
sequelpro-bf7ed8561accb5a3ce2e7cb8f681017adcd8f055.tar.bz2
sequelpro-bf7ed8561accb5a3ce2e7cb8f681017adcd8f055.zip
In the database drop down, visually separate 'system' databases (i.e. mysql and information_schema) from 'user' databases by placing them at the top.
Diffstat (limited to 'Source/TableDocument.m')
-rw-r--r--Source/TableDocument.m45
1 files changed, 32 insertions, 13 deletions
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 25524389..0bd76f6f 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -909,8 +909,7 @@
*/
- (IBAction)setDatabases:(id)sender;
{
- if (!chooseDatabaseButton)
- return;
+ if (!chooseDatabaseButton) return;
[chooseDatabaseButton removeAllItems];
@@ -922,23 +921,43 @@
MCPResult *queryResult = [mySQLConnection listDBs];
- if ([queryResult numOfRows]) {
- [queryResult dataSeek:0];
- }
-
- // if([allDatabases count])
- // [allDatabases removeAllObjects];
-
- if(allDatabases)
- [allDatabases release];
+ if ([queryResult numOfRows]) [queryResult dataSeek:0];
+ if (allDatabases) [allDatabases release];
+
allDatabases = [[NSMutableArray alloc] initWithCapacity:[queryResult numOfRows]];
+ NSMutableArray *systemDatabases = [NSMutableArray array];
+
for (int i = 0 ; i < [queryResult numOfRows] ; i++)
- [allDatabases addObject:NSArrayObjectAtIndex([queryResult fetchRowAsArray], 0)];
+ {
+ NSString *database = NSArrayObjectAtIndex([queryResult fetchRowAsArray], 0);
+
+ // If the database is either information_schema or mysql then it is classed as a system table
+ if ([database isEqualToString:@"information_schema"] || [database isEqualToString:@"mysql"]) {
+ [systemDatabases addObject:database];
+ }
+ else {
+ [allDatabases addObject:database];
+ }
+ }
+
+ // Add system databases
+ for (NSString *db in systemDatabases)
+ {
+ [chooseDatabaseButton addItemWithTitle:db];
+ }
+
+ // Add a separator between the system and user databases
+ if ([systemDatabases count] > 0) {
+ [[chooseDatabaseButton menu] addItem:[NSMenuItem separatorItem]];
+ }
- for (id db in allDatabases)
+ // Add user databases
+ for (NSString *db in allDatabases)
+ {
[chooseDatabaseButton addItemWithTitle:db];
+ }
(![self database]) ? [chooseDatabaseButton selectItemAtIndex:0] : [chooseDatabaseButton selectItemWithTitle:[self database]];
}