Skip to content

Commit

Permalink
Add sys database to the list of system databases.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuconnolly committed Jun 18, 2018
1 parent 6639af7 commit 5d99aca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
1 change: 1 addition & 0 deletions Source/SPConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ extern NSString *SPDefaultMonospacedFontName;
extern NSString *SPMySQLDatabase;
extern NSString *SPMySQLInformationSchemaDatabase;
extern NSString *SPMySQLPerformanceSchemaDatabase;
extern NSString *SPMySQLSysDatabase;

// Table view drag types
extern NSString *SPDefaultPasteboardDragType;
Expand Down
1 change: 1 addition & 0 deletions Source/SPConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
NSString *SPMySQLDatabase = @"mysql";
NSString *SPMySQLInformationSchemaDatabase = @"information_schema";
NSString *SPMySQLPerformanceSchemaDatabase = @"performance_schema";
NSString *SPMySQLSysDatabase = @"sys";

// Table view drag types
NSString *SPDefaultPasteboardDragType = @"SequelProPasteboard";
Expand Down
22 changes: 9 additions & 13 deletions Source/SPDatabaseDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,6 @@ - (SPMySQLConnection *)getConnection
*/
- (IBAction)setDatabases:(id)sender;
{
#ifndef SP_CODA /* ui manipulation */

if (!chooseDatabaseButton) return;

[chooseDatabaseButton removeAllItems];
Expand All @@ -635,7 +633,6 @@ - (IBAction)setDatabases:(id)sender;
[[chooseDatabaseButton menu] addItemWithTitle:NSLocalizedString(@"Add Database...", @"menu item to add db") action:@selector(addDatabase:) keyEquivalent:@""];
[[chooseDatabaseButton menu] addItemWithTitle:NSLocalizedString(@"Refresh Databases", @"menu item to refresh databases") action:@selector(setDatabases:) keyEquivalent:@""];
[[chooseDatabaseButton menu] addItem:[NSMenuItem separatorItem]];
#endif

if (allDatabases) SPClear(allDatabases);
if (allSystemDatabases) SPClear(allSystemDatabases);
Expand All @@ -645,25 +642,25 @@ - (IBAction)setDatabases:(id)sender;
allDatabases = [[NSMutableArray alloc] initWithCapacity:[theDatabaseList count]];
allSystemDatabases = [[NSMutableArray alloc] initWithCapacity:2];

for (NSString *databaseName in theDatabaseList) {
for (NSString *databaseName in theDatabaseList)
{
// If the database is either information_schema or mysql then it is classed as a
// system table; similarly, for 5.5.3+, performance_schema
// system database; similarly, performance_schema in 5.5.3+ and sys in 5.7.7+
if ([databaseName isEqualToString:SPMySQLDatabase] ||
[databaseName isEqualToString:SPMySQLInformationSchemaDatabase] ||
[databaseName isEqualToString:SPMySQLPerformanceSchemaDatabase]) {
[databaseName isEqualToString:SPMySQLPerformanceSchemaDatabase] ||
[databaseName isEqualToString:SPMySQLSysDatabase]) {
[allSystemDatabases addObject:databaseName];
}
else {
[allDatabases addObject:databaseName];
}
}

#ifndef SP_CODA /* ui manipulation */
// Add system databases
for (NSString *db in allSystemDatabases)
for (NSString *database in allSystemDatabases)
{
[chooseDatabaseButton addItemWithTitle:db];
[chooseDatabaseButton addItemWithTitle:database];
}

// Add a separator between the system and user databases
Expand All @@ -672,13 +669,12 @@ - (IBAction)setDatabases:(id)sender;
}

// Add user databases
for (NSString *db in allDatabases)
for (NSString *database in allDatabases)
{
[chooseDatabaseButton addItemWithTitle:db];
[chooseDatabaseButton addItemWithTitle:database];
}

(![self database]) ? [chooseDatabaseButton selectItemAtIndex:0] : [chooseDatabaseButton selectItemWithTitle:[self database]];
#endif
}

#ifndef SP_CODA /* chooseDatabase: */
Expand Down

0 comments on commit 5d99aca

Please sign in to comment.