From 310fb079c75d551bf2a129b69c897905ca83e061 Mon Sep 17 00:00:00 2001 From: Stuart Connolly Date: Thu, 28 Aug 2014 19:08:14 +0100 Subject: Resolve #1938: In the query console display the database the query was executed in. --- Interfaces/English.lproj/Console.xib | 391 +++++++++++++++++++++++++----- Resources/Plists/PreferenceDefaults.plist | 2 + Source/SPConnectionDelegate.m | 40 +-- Source/SPConsoleMessage.h | 12 +- Source/SPConsoleMessage.m | 9 +- Source/SPConstants.h | 1 + Source/SPConstants.m | 1 + Source/SPQueryConsoleDataSource.m | 10 +- Source/SPQueryController.h | 24 +- Source/SPQueryController.m | 52 ++-- Source/SPQueryControllerInitializer.m | 1 + Source/SPTableContent.m | 8 +- 12 files changed, 448 insertions(+), 103 deletions(-) diff --git a/Interfaces/English.lproj/Console.xib b/Interfaces/English.lproj/Console.xib index 85f0063a..be2de0da 100644 --- a/Interfaces/English.lproj/Console.xib +++ b/Interfaces/English.lproj/Console.xib @@ -2,13 +2,13 @@ 1060 - 13B3116 - 4514 - 1265 - 696.00 + 13E28 + 5056 + 1265.21 + 698.00 com.apple.InterfaceBuilder.CocoaPlugin - 4514 + 5056 NSButton @@ -63,7 +63,7 @@ {575, 130} - + 256 @@ -79,6 +79,8 @@ {{62, 0}, {513, 23}} + + YES 134217728 @@ -100,6 +102,8 @@ 289 {{399, 2}, {166, 17}} + + YES 67108864 @@ -125,6 +129,8 @@ 266 {{10, 174}, {531, 19}} + + YES 342884416 @@ -203,6 +209,8 @@ 256 {576, 126} + + YES NO YES @@ -211,6 +219,8 @@ 256 {576, 17} + + @@ -292,11 +302,37 @@ YES - + + messageDatabase + 64 + 50 + 1000 + + 75497536 + 2048 + Database + + + + + + 337641536 + 133120 + Text Cell + + + + + + 3 + YES + + + message - 367 - 10 - 10000 + 300 + 50 + 3.4028234663852886e+38 75497536 2048 @@ -305,16 +341,16 @@ - - 67108928 - 133376 + + 337641536 + 133120 Text Cell - 1 + 3 YES @@ -345,16 +381,33 @@ {{1, 17}, {576, 126}} + 4 + + + 2338 + + + + {{1, 0}, {576, 17}} + + + + + + 4 + -2147483392 {{539, 1}, {15, 124}} + + NO _doScroller: @@ -363,32 +416,22 @@ -2147483392 - {{-100, -100}, {238, 15}} + {{1, 127}, {576, 16}} + + NO 1 _doScroller: 0.57142859697341919 - - - 2338 - - - - {{1, 0}, {576, 17}} - - - - - 4 - {{-1, 22}, {578, 144}} - - 133650 + + + 133682 @@ -403,6 +446,8 @@ -2147482359 {{549, 175}, {16, 16}} + + 20746 16 100 @@ -412,6 +457,8 @@ 292 {{30, -1}, {32, 25}} + + YES -2080374784 @@ -441,6 +488,8 @@ 292 {{-10, 0}, {46, 25}} + + YES -2076180416 @@ -500,6 +549,17 @@ _popUpItemAction: + + + Show Databases + + 2147483647 + 1 + + + _popUpItemAction: + + YES @@ -536,7 +596,7 @@ - 1 + -1 YES 1 YES @@ -549,6 +609,8 @@ 290 {{67, 4}, {375, 14}} + + YES 68157504 @@ -569,6 +631,9 @@ {575, 203} + + + {{0, 0}, {1440, 878}} {575, 152} @@ -580,21 +645,23 @@ 268 - + 268 - {{10, 8}, {260, 18}} + {{10, 7}, {136, 18}} + _NS:9 YES - + -2080374784 - 0 - Include Connections + 268435456 + Include Databases - + _NS:9 + 1211912448 2 - + NSImage NSSwitch @@ -608,11 +675,36 @@ NO + + + 268 + {{10, 31}, {260, 18}} + + + YES + + -2080374784 + 0 + Include Connections + + + 1211912448 + 2 + + + + + 200 + 25 + + NO + 268 - {{10, 32}, {260, 18}} + {{10, 55}, {260, 18}} + YES -2080374784 @@ -622,7 +714,7 @@ 1211912448 2 - + @@ -632,7 +724,8 @@ NO - {278, 56} + {278, 79} + NSView @@ -791,6 +884,22 @@ 58 + + + toggleShowDatabases: + + + + qJH-at-hGq + + + + includeDatabaseButton + + + + yvJ-aZ-4by + delegate @@ -899,6 +1008,26 @@ 124 + + + value: values.ConsoleShowDatabases + + + + + + value: values.ConsoleShowDatabases + value + values.ConsoleShowDatabases + + NSConditionallySetsEnabled + + + 2 + + + pY8-9m-mAK + @@ -1003,6 +1132,7 @@ + saveLogView @@ -1090,6 +1220,7 @@ + @@ -1165,7 +1296,8 @@ - + + @@ -1186,27 +1318,58 @@ - 17 - + 114 + + + + + 19 + + + + + wyq-H4-GHT + - + - 20 - - + g2D-wF-fcB + + - 114 - - + TqS-5i-3PL + + + + + - 19 - - + REt-h0-g0b + + + + + QeH-Fu-VaB + + + + + bTU-iR-4Vf + + + + + + + + kLs-LH-NAM + + @@ -1229,10 +1392,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin {{277, 574}, {575, 203}} @@ -1267,13 +1428,129 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - + + + + SPQueryController + NSWindowController + + id + id + id + id + id + id + id + id + + + + clearConsole: + id + + + copy: + id + + + saveConsoleAs: + id + + + toggleShowConnections: + id + + + toggleShowDatabases: + id + + + toggleShowHelpStatements: + id + + + toggleShowSelectShowStatements: + id + + + toggleShowTimeStamps: + id + + + + NSButton + NSSearchField + NSTableView + NSButton + NSButton + NSButton + NSTextField + NSProgressIndicator + NSButton + NSView + + + + clearConsoleButton + NSButton + + + consoleSearchField + NSSearchField + + + consoleTableView + NSTableView + + + includeConnectionButton + NSButton + + + includeDatabaseButton + NSButton + + + includeTimeStampsButton + NSButton + + + loggingDisabledTextField + NSTextField + + + progressIndicator + NSProgressIndicator + + + saveConsoleButton + NSButton + + + saveLogView + NSView + + + + IBProjectSource + ./Classes/SPQueryController.h + + + + 0 IBCocoaFramework YES diff --git a/Resources/Plists/PreferenceDefaults.plist b/Resources/Plists/PreferenceDefaults.plist index 43ed5c1a..aec5bae9 100644 --- a/Resources/Plists/PreferenceDefaults.plist +++ b/Resources/Plists/PreferenceDefaults.plist @@ -18,6 +18,8 @@ ConsoleShowConnections + ConsoleShowDatabases + ConsoleShowHelps ConsoleShowSelectsAndShows diff --git a/Source/SPConnectionDelegate.m b/Source/SPConnectionDelegate.m index b7bbc47e..caf7926c 100644 --- a/Source/SPConnectionDelegate.m +++ b/Source/SPConnectionDelegate.m @@ -48,11 +48,11 @@ { #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 @@ { #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 @@ */ - (NSString *)keychainPasswordForConnection:(SPMySQLConnection *)connection { - // If no keychain item is available, return an empty password if (![connectionController connectionKeychainItemName]) return nil; @@ -96,23 +95,26 @@ */ - (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 @@ */ - (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") + ); } /** diff --git a/Source/SPConsoleMessage.h b/Source/SPConsoleMessage.h index 7fe1b711..e79845ae 100644 --- a/Source/SPConsoleMessage.h +++ b/Source/SPConsoleMessage.h @@ -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 diff --git a/Source/SPConsoleMessage.m b/Source/SPConsoleMessage.m index 0a5c2bcf..6ada323a 100644 --- a/Source/SPConsoleMessage.m +++ b/Source/SPConsoleMessage.m @@ -35,24 +35,26 @@ @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 @@ { [message release], message = nil; [messageDate release], messageDate = nil; + [messageDatabase release], messageDatabase = nil; [messageConnection release], messageConnection = nil; [super dealloc]; diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 1778a1d5..76f51f49 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -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; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index a1bcce8d..6b986506 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -163,6 +163,7 @@ NSString *SPConsoleShowHelps = @"ConsoleShowHelps"; NSString *SPConsoleShowSelectsAndShows = @"ConsoleShowSelectsAndShows"; NSString *SPConsoleShowTimestamps = @"ConsoleShowTimestamps"; NSString *SPConsoleShowConnections = @"ConsoleShowConnections"; +NSString *SPConsoleShowDatabases = @"ConsoleShowDatabases"; NSString *SPEditInSheetEnabled = @"EditInSheetEnabled"; NSString *SPTableInformationPanelCollapsed = @"TableInformationPanelCollapsed"; NSString *SPTableColumnWidths = @"tableColumnWidths"; diff --git a/Source/SPQueryConsoleDataSource.m b/Source/SPQueryConsoleDataSource.m index 343f2dcd..eaac2151 100644 --- a/Source/SPQueryConsoleDataSource.m +++ b/Source/SPQueryConsoleDataSource.m @@ -54,8 +54,12 @@ static NSUInteger SPMessageTruncateCharacterLength = 256; { #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 @@ static NSUInteger SPMessageTruncateCharacterLength = 256; returnValue = object; } - + + if (!returnValue) return returnValue; + NSMutableDictionary *stringAtributes = nil; if (consoleFont) { diff --git a/Source/SPQueryController.h b/Source/SPQueryController.h index ce48dced..8d128fe3 100644 --- a/Source/SPQueryController.h +++ b/Source/SPQueryController.h @@ -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; diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index f31ce808..01cb50e1 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -39,6 +39,7 @@ NSString *SPQueryConsoleWindowAutoSaveName = @"QueryConsole"; NSString *SPTableViewDateColumnID = @"messageDate"; NSString *SPTableViewConnectionColumnID = @"messageConnection"; +NSString *SPTableViewDatabaseColumnID = @"messageDatabase"; #endif @interface SPQueryController () @@ -46,8 +47,8 @@ NSString *SPTableViewConnectionColumnID = @"messageConnection"; - (void)_updateFilterState; - (void)_allowFilterClearOrSave:(NSNumber *)enabled; - (BOOL)_messageMatchesCurrentFilters:(NSString *)message; -- (NSString *)_getConsoleStringWithTimeStamps:(BOOL)timeStamps connections:(BOOL)connections; -- (void)_addMessageToConsole:(NSString *)message connection:(NSString *)connection isError:(BOOL)error; +- (NSString *)_getConsoleStringWithTimeStamps:(BOOL)timeStamps connections:(BOOL)connections databases:(BOOL)databases; +- (void)_addMessageToConsole:(NSString *)message connection:(NSString *)connection isError:(BOOL)error database:(NSString *)database; @end @@ -161,6 +162,7 @@ static SPQueryController *sharedQueryController = nil; BOOL includeTimestamps = ![[consoleTableView tableColumnWithIdentifier:SPTableViewDateColumnID] isHidden]; BOOL includeConnections = ![[consoleTableView tableColumnWithIdentifier:SPTableViewConnectionColumnID] isHidden]; + BOOL includeDatabases = ![[consoleTableView tableColumnWithIdentifier:SPTableViewDatabaseColumnID] isHidden]; [string setString:@""]; @@ -181,7 +183,12 @@ static SPQueryController *sharedQueryController = nil; [string appendString:@" "]; } - if (includeTimestamps || includeConnections) [string appendString:@"*/ "]; + if (includeDatabases) { + [string appendString:[message messageDatabase]]; + [string appendString:@" "]; + } + + if (includeTimestamps || includeConnections || includeDatabases) [string appendString:@"*/ "]; [string appendFormat:@"%@\n", [message message]]; } @@ -228,10 +235,12 @@ static SPQueryController *sharedQueryController = nil; [panel setAccessoryView:saveLogView]; [panel setNameFieldStringValue:NSLocalizedString(@"ConsoleLog", @"Console : Save as : Initial filename")]; + [panel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger returnCode) { if (returnCode == NSOKButton) { [[self _getConsoleStringWithTimeStamps:[includeTimeStampsButton state] - connections:[includeConnectionButton state]] writeToFile:[[panel URL] path] atomically:YES encoding:NSUTF8StringEncoding error:NULL]; + connections:[includeConnectionButton state] + databases:[includeDatabaseButton state]] writeToFile:[[panel URL] path] atomically:YES encoding:NSUTF8StringEncoding error:NULL]; } }]; #endif @@ -243,17 +252,27 @@ static SPQueryController *sharedQueryController = nil; - (IBAction)toggleShowTimeStamps:(id)sender { #ifndef SP_CODA - [[consoleTableView tableColumnWithIdentifier:SPTableViewDateColumnID] setHidden:([sender state])]; + [[consoleTableView tableColumnWithIdentifier:SPTableViewDateColumnID] setHidden:[sender state]]; #endif } /** - * Toggles the display of message connections column in the table view. + * Toggles the display of the message connections column in the table view. */ - (IBAction)toggleShowConnections:(id)sender { #ifndef SP_CODA - [[consoleTableView tableColumnWithIdentifier:SPTableViewConnectionColumnID] setHidden:([sender state])]; + [[consoleTableView tableColumnWithIdentifier:SPTableViewConnectionColumnID] setHidden:[sender state]]; +#endif +} + +/** + * Toggles the display of the message databases column in the table view. + */ +- (IBAction)toggleShowDatabases:(id)sender +{ +#ifndef SP_CODA + [[consoleTableView tableColumnWithIdentifier:SPTableViewDatabaseColumnID] setHidden:[sender state]]; #endif } @@ -286,20 +305,20 @@ static SPQueryController *sharedQueryController = nil; /** * Shows the supplied message from the supplied connection in the console. */ -- (void)showMessageInConsole:(NSString *)message connection:(NSString *)connection +- (void)showMessageInConsole:(NSString *)message connection:(NSString *)connection database:(NSString *)database { #ifndef SP_CODA - [self _addMessageToConsole:message connection:connection isError:NO]; + [self _addMessageToConsole:message connection:connection isError:NO database:database]; #endif } /** * Shows the supplied error from the supplied connection in the console. */ -- (void)showErrorInConsole:(NSString *)error connection:(NSString *)connection +- (void)showErrorInConsole:(NSString *)error connection:(NSString *)connection database:(NSString *)database { #ifndef SP_CODA - [self _addMessageToConsole:error connection:connection isError:YES]; + [self _addMessageToConsole:error connection:connection isError:YES database:database]; #endif } @@ -538,7 +557,7 @@ static SPQueryController *sharedQueryController = nil; * Creates and returns a string made entirely of all of the console's messages and includes the message * time stamp and connection if specified. */ -- (NSString *)_getConsoleStringWithTimeStamps:(BOOL)timeStamps connections:(BOOL)connections +- (NSString *)_getConsoleStringWithTimeStamps:(BOOL)timeStamps connections:(BOOL)connections databases:(BOOL)databases { NSMutableString *consoleString = [NSMutableString string]; @@ -563,6 +582,11 @@ static SPQueryController *sharedQueryController = nil; [consoleString appendString:@" "]; } + if (databases && [message messageDatabase]) { + [consoleString appendString:[message messageDatabase]]; + [consoleString appendString:@" "]; + } + // Close the comment if (timeStamps || connections) [consoleString appendString:@"*/ "]; @@ -578,7 +602,7 @@ static SPQueryController *sharedQueryController = nil; /** * Adds the supplied message to the query console. */ -- (void)_addMessageToConsole:(NSString *)message connection:(NSString *)connection isError:(BOOL)error +- (void)_addMessageToConsole:(NSString *)message connection:(NSString *)connection isError:(BOOL)error database:(NSString *)database { #ifndef SP_CODA NSString *messageTemp = [[message stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; @@ -586,7 +610,7 @@ static SPQueryController *sharedQueryController = nil; // Only append a semi-colon (;) if the supplied message is not an error if (!error) messageTemp = [messageTemp stringByAppendingString:@";"]; - SPConsoleMessage *consoleMessage = [SPConsoleMessage consoleMessageWithMessage:messageTemp date:[NSDate date] connection:connection]; + SPConsoleMessage *consoleMessage = [SPConsoleMessage consoleMessageWithMessage:messageTemp date:[NSDate date] connection:connection database:database]; [consoleMessage setIsError:error]; diff --git a/Source/SPQueryControllerInitializer.m b/Source/SPQueryControllerInitializer.m index 93854863..8890a607 100644 --- a/Source/SPQueryControllerInitializer.m +++ b/Source/SPQueryControllerInitializer.m @@ -57,6 +57,7 @@ static NSString *SPCompletionTokensSnippetsKey = @"function_argument_snippets"; // Show/hide table columns [[consoleTableView tableColumnWithIdentifier:SPTableViewDateColumnID] setHidden:![prefs boolForKey:SPConsoleShowTimestamps]]; [[consoleTableView tableColumnWithIdentifier:SPTableViewConnectionColumnID] setHidden:![prefs boolForKey:SPConsoleShowConnections]]; + [[consoleTableView tableColumnWithIdentifier:SPTableViewDatabaseColumnID] setHidden:![prefs boolForKey:SPConsoleShowDatabases]]; showSelectStatementsAreDisabled = ![prefs boolForKey:SPConsoleShowSelectsAndShows]; showHelpStatementsAreDisabled = ![prefs boolForKey:SPConsoleShowHelps]; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 8e537178..dcf22d49 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -2956,13 +2956,17 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [tableValues removeRowAtIndex:currentlyEditingRow]; [self updateCountText]; isEditingNewRow = NO; - } else { + } + else { [tableValues replaceRowAtIndex:currentlyEditingRow withRowContents:oldRow]; } + isEditingRow = NO; currentlyEditingRow = -1; [tableContentView reloadData]; - [[SPQueryController sharedQueryController] showErrorInConsole:NSLocalizedString(@"/* WARNING: No rows have been affected */\n", @"warning shown in the console when no rows have been affected after writing to the db") connection:[tableDocumentInstance name]]; + + [[SPQueryController sharedQueryController] showErrorInConsole:NSLocalizedString(@"/* WARNING: No rows have been affected */\n", @"warning shown in the console when no rows have been affected after writing to the db") connection:[tableDocumentInstance name] database:[tableDocumentInstance database]]; + return YES; // On success... -- cgit v1.2.3