Permalink
Browse files

Add sys database to the list of system databases.

  • Loading branch information...
stuconnolly committed Jun 18, 2018
1 parent 6639af7 commit 5d99aca6ff1950eba0d53048d7de1749aaaa72d6
Showing with 11 additions and 13 deletions.
  1. +1 −0 Source/SPConstants.h
  2. +1 −0 Source/SPConstants.m
  3. +9 −13 Source/SPDatabaseDocument.m
@@ -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;
@@ -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";
@@ -624,8 +624,6 @@ - (SPMySQLConnection *)getConnection
*/
- (IBAction)setDatabases:(id)sender;
{
#ifndef SP_CODA /* ui manipulation */
if (!chooseDatabaseButton) return;
[chooseDatabaseButton removeAllItems];
@@ -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);
@@ -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
@@ -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: */

0 comments on commit 5d99aca

Please sign in to comment.