Permalink
Browse files

Resolve #1938: In the query console display the database the query wa…

…s executed in.
  • Loading branch information...
stuconnolly committed Aug 28, 2014
1 parent e3c342d commit 310fb079c75d551bf2a129b69c897905ca83e061

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -18,6 +18,8 @@
<true/>
<key>ConsoleShowConnections</key>
<true/>
<key>ConsoleShowDatabases</key>
<true/>
<key>ConsoleShowHelps</key>
<true/>
<key>ConsoleShowSelectsAndShows</key>
@@ -48,11 +48,11 @@ - (void)willQueryString:(NSString *)query connection:(id)connection
{
#ifndef SP_CODA
if ([prefs boolForKey:SPConsoleEnableLogging]) {
if ((_queryMode == SPInterfaceQueryMode && [prefs boolForKey:SPConsoleEnableInterfaceLogging])
|| (_queryMode == SPCustomQueryQueryMode && [prefs boolForKey:SPConsoleEnableCustomQueryLogging])
|| (_queryMode == SPImportExportQueryMode && [prefs boolForKey:SPConsoleEnableImportExportLogging]))
if ((_queryMode == SPInterfaceQueryMode && [prefs boolForKey:SPConsoleEnableInterfaceLogging]) ||
(_queryMode == SPCustomQueryQueryMode && [prefs boolForKey:SPConsoleEnableCustomQueryLogging]) ||
(_queryMode == SPImportExportQueryMode && [prefs boolForKey:SPConsoleEnableImportExportLogging]))
{
[[SPQueryController sharedQueryController] showMessageInConsole:query connection:[self name]];
[[SPQueryController sharedQueryController] showMessageInConsole:query connection:[self name] database:[self database]];
}
}
#endif
@@ -65,7 +65,7 @@ - (void)queryGaveError:(NSString *)error connection:(id)connection
{
#ifndef SP_CODA
if ([prefs boolForKey:SPConsoleEnableLogging] && [prefs boolForKey:SPConsoleEnableErrorLogging]) {
[[SPQueryController sharedQueryController] showErrorInConsole:error connection:[self name]];
[[SPQueryController sharedQueryController] showErrorInConsole:error connection:[self name] database:[self database]];
}
#endif
}
@@ -75,7 +75,6 @@ - (void)queryGaveError:(NSString *)error connection:(id)connection
*/
- (NSString *)keychainPasswordForConnection:(SPMySQLConnection *)connection
{
// If no keychain item is available, return an empty password
if (![connectionController connectionKeychainItemName]) return nil;
@@ -96,23 +95,26 @@ - (NSString *)keychainPasswordForConnection:(SPMySQLConnection *)connection
*/
- (NSString *)keychainPasswordForSSHConnection:(SPMySQLConnection *)connection
{
// If no keychain item is available, return an empty password
if (![connectionController connectionKeychainItemName]) return @"";
// Otherwise, pull the password from the keychain using the details from this connection
SPKeychain *keychain = [[SPKeychain alloc] init];
NSString *connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keyChainID]] retain];
NSString *connectionSSHKeychainItemAccount = [[keychain accountForSSHUser:[connectionController sshUser] sshHost:[connectionController sshHost]] retain];
NSString *sshpw = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount];
if (!sshpw || ![sshpw length])
sshpw = @"";
NSString *sshPassword = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount];
if (!sshPassword || ![sshPassword length]) {
sshPassword = @"";
}
if (connectionSSHKeychainItemName) [connectionSSHKeychainItemName release];
if (connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release];
if(connectionSSHKeychainItemName) [connectionSSHKeychainItemName release];
if(connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release];
[keychain release];
return sshpw;
return sshPassword;
}
/**
@@ -121,7 +123,17 @@ - (NSString *)keychainPasswordForSSHConnection:(SPMySQLConnection *)connection
*/
- (void)noConnectionAvailable:(id)connection
{
SPBeginAlertSheet(NSLocalizedString(@"No connection available", @"no connection available message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self parentWindow], self, nil, nil, NSLocalizedString(@"An error has occured and there doesn't seem to be a connection available.", @"no connection available informatie message"));
SPBeginAlertSheet(
NSLocalizedString(@"No connection available", @"no connection available message"),
NSLocalizedString(@"OK", @"OK button"),
nil,
nil,
[self parentWindow],
self,
nil,
nil,
NSLocalizedString(@"An error has occured and there doesn't seem to be a connection available.", @"no connection available informatie message")
);
}
/**
@@ -34,16 +34,24 @@
NSDate *messageDate;
NSString *message;
NSString *messageDatabase;
NSString *messageConnection;
}
@property (readwrite, assign) BOOL isError;
@property (readwrite, retain) NSDate *messageDate;
@property (readwrite, retain) NSString *message;
@property (readwrite, retain) NSString *messageDatabase;
@property (readwrite, retain) NSString *messageConnection;
+ (SPConsoleMessage *)consoleMessageWithMessage:(NSString *)consoleMessage date:(NSDate *)date connection:(NSString *)connection;
+ (SPConsoleMessage *)consoleMessageWithMessage:(NSString *)consoleMessage
date:(NSDate *)date
connection:(NSString *)connection
database:(NSString *)database;
- (id)initWithMessage:(NSString *)message date:(NSDate *)date connection:(NSString *)connection;
- (id)initWithMessage:(NSString *)message
date:(NSDate *)date
connection:(NSString *)connection
database:(NSString *)database;
@end
@@ -35,24 +35,26 @@ @implementation SPConsoleMessage
@synthesize isError;
@synthesize messageDate;
@synthesize message;
@synthesize messageDatabase;
@synthesize messageConnection;
/**
* Returns a new console message instance using the suppled message, date and connection.
*/
+ (SPConsoleMessage *)consoleMessageWithMessage:(NSString *)message date:(NSDate *)date connection:(NSString *)connection
+ (SPConsoleMessage *)consoleMessageWithMessage:(NSString *)message date:(NSDate *)date connection:(NSString *)connection database:(NSString *)database
{
return [[[SPConsoleMessage alloc] initWithMessage:message date:date connection:connection] autorelease];
return [[[SPConsoleMessage alloc] initWithMessage:message date:date connection:connection database:database] autorelease];
}
/**
* Initializes a new console message instance using the suppled message, date and connection.
*/
- (id)initWithMessage:(NSString *)consoleMessage date:(NSDate *)date connection:(NSString *)connection
- (id)initWithMessage:(NSString *)consoleMessage date:(NSDate *)date connection:(NSString *)connection database:(NSString *)database
{
if ((self = [super init])) {
[self setMessageDate:date];
[self setMessage:consoleMessage];
[self setMessageDatabase:database];
[self setMessageConnection:connection];
}
@@ -65,6 +67,7 @@ - (void)dealloc
{
[message release], message = nil;
[messageDate release], messageDate = nil;
[messageDatabase release], messageDatabase = nil;
[messageConnection release], messageConnection = nil;
[super dealloc];
@@ -355,6 +355,7 @@ extern NSString *SPLastUsedVersion;
// GUI Prefs
extern NSString *SPConsoleShowTimestamps;
extern NSString *SPConsoleShowConnections;
extern NSString *SPConsoleShowDatabases;
extern NSString *SPConsoleShowSelectsAndShows;
extern NSString *SPConsoleShowHelps;
extern NSString *SPEditInSheetEnabled;
@@ -163,6 +163,7 @@
NSString *SPConsoleShowSelectsAndShows = @"ConsoleShowSelectsAndShows";
NSString *SPConsoleShowTimestamps = @"ConsoleShowTimestamps";
NSString *SPConsoleShowConnections = @"ConsoleShowConnections";
NSString *SPConsoleShowDatabases = @"ConsoleShowDatabases";
NSString *SPEditInSheetEnabled = @"EditInSheetEnabled";
NSString *SPTableInformationPanelCollapsed = @"TableInformationPanelCollapsed";
NSString *SPTableColumnWidths = @"tableColumnWidths";
@@ -54,8 +54,12 @@ - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColum
{
#ifndef SP_CODA
NSString *returnValue = nil;
NSString *identifier = [tableColumn identifier];
if (!identifier) return returnValue;
id object = [[messagesVisibleSet objectAtIndex:row] valueForKey:[tableColumn identifier]];
id object = [[messagesVisibleSet objectAtIndex:row] valueForKey:identifier];
if ([[tableColumn identifier] isEqualToString:SPTableViewDateColumnID]) {
@@ -68,7 +72,9 @@ - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColum
returnValue = object;
}
if (!returnValue) return returnValue;
NSMutableDictionary *stringAtributes = nil;
if (consoleFont) {
@@ -32,6 +32,7 @@
extern NSString *SPQueryConsoleWindowAutoSaveName;
extern NSString *SPTableViewDateColumnID;
extern NSString *SPTableViewConnectionColumnID;
extern NSString *SPTableViewDatabaseColumnID;
#endif
@interface SPQueryController : NSWindowController
@@ -42,22 +43,26 @@ extern NSString *SPTableViewConnectionColumnID;
IBOutlet NSSearchField *consoleSearchField;
IBOutlet NSTextField *loggingDisabledTextField;
IBOutlet NSProgressIndicator *progressIndicator;
IBOutlet NSButton *includeTimeStampsButton, *includeConnectionButton, *saveConsoleButton, *clearConsoleButton;
NSFont *consoleFont;
NSMutableArray *messagesFullSet, *messagesFilteredSet, *messagesVisibleSet;
IBOutlet NSButton *includeTimeStampsButton;
IBOutlet NSButton *includeConnectionButton;
IBOutlet NSButton *includeDatabaseButton;
IBOutlet NSButton *saveConsoleButton;
IBOutlet NSButton *clearConsoleButton;
BOOL showSelectStatementsAreDisabled;
BOOL showHelpStatementsAreDisabled;
BOOL filterIsActive;
BOOL allowConsoleUpdate;
NSFont *consoleFont;
NSMutableString *activeFilterString;
NSMutableArray *messagesFullSet, *messagesFilteredSet, *messagesVisibleSet;
// DocumentsController
NSUInteger untitledDocumentCounter;
NSMutableDictionary *favoritesContainer;
NSMutableDictionary *historyContainer;
NSMutableDictionary *contentFilterContainer;
NSUInteger untitledDocumentCounter;
NSUInteger numberOfMaxAllowedHistory;
#endif
@@ -84,6 +89,7 @@ extern NSString *SPTableViewConnectionColumnID;
- (IBAction)saveConsoleAs:(id)sender;
- (IBAction)toggleShowTimeStamps:(id)sender;
- (IBAction)toggleShowConnections:(id)sender;
- (IBAction)toggleShowDatabases:(id)sender;
- (IBAction)toggleShowSelectShowStatements:(id)sender;
- (IBAction)toggleShowHelpStatements:(id)sender;
@@ -92,8 +98,8 @@ extern NSString *SPTableViewConnectionColumnID;
- (BOOL)allowConsoleUpdate;
- (void)setAllowConsoleUpdate:(BOOL)allowUpdate;
- (void)showMessageInConsole:(NSString *)message connection:(NSString *)connection;
- (void)showErrorInConsole:(NSString *)error connection:(NSString *)connection;
- (void)showMessageInConsole:(NSString *)message connection:(NSString *)connection database:(NSString *)database;
- (void)showErrorInConsole:(NSString *)error connection:(NSString *)connection database:(NSString *)database;
- (NSUInteger)consoleMessageCount;
Oops, something went wrong.

0 comments on commit 310fb07

Please sign in to comment.