From 0efe2f26810e8849035ed77ddb2e642643345dee Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 21 Jul 2009 10:12:46 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20bug=20if=20the=20table=20sorting=20?= =?UTF-8?q?query=20in=20Custom=20Query=20gave=20an=20error=20-=20SP=20trie?= =?UTF-8?q?d=20to=20select=20the=20erroneous=20part=20in=20customQueryView?= =?UTF-8?q?=20which=20could=20lead=20to=20an=20range=20exception=20-=20now?= =?UTF-8?q?=20it=20shows=20a=20proper=20error=20message=20-=20it=20suppres?= =?UTF-8?q?ses=20column=20highlighting=20and=20setting=20of=20the=20NSSort?= =?UTF-8?q?Indicator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CustomQuery.h | 3 ++- Source/CustomQuery.m | 29 ++++++++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Source/CustomQuery.h b/Source/CustomQuery.h index 47be44c7..57b8ee85 100644 --- a/Source/CustomQuery.h +++ b/Source/CustomQuery.h @@ -95,7 +95,8 @@ NSArray *cqColumnDefinition; NSString *lastExecutedQuery; - BOOL tableReloadAfterEdting; + BOOL tableReloadAfterEditing; + BOOL queryIsTableSorter; BOOL isDesc; NSNumber *sortField; BOOL tempAlertWasShown; // a temp value for nightly builts diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 2457f932..c870237c 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -75,7 +75,7 @@ // Reset queryStartPosition queryStartPosition = 0; - tableReloadAfterEdting = NO; + tableReloadAfterEditing = NO; [self performQueries:queries]; // If no error was selected reconstruct a given selection @@ -129,7 +129,7 @@ [textView insertText:@""]; [textView setSelectedRange:selectedRange]; - tableReloadAfterEdting = NO; + tableReloadAfterEditing = NO; [self performQueries:queries]; } @@ -420,7 +420,7 @@ [customQueryView scrollColumnToVisible:0]; // Remove all the columns - if(!tableReloadAfterEdting) { + if(!tableReloadAfterEditing) { theColumns = [customQueryView tableColumns]; while ([theColumns count]) { [customQueryView removeTableColumn:NSArrayObjectAtIndex(theColumns, 0)]; @@ -523,7 +523,7 @@ // if(!queriesSeparatedByDelimiter) // TODO: How to combine queries delimited by DELIMITER? usedQuery = [[NSString stringWithString:[tempQueries componentsJoinedByString:@";\n"]] retain]; - if(!tableReloadAfterEdting) + if(!tableReloadAfterEditing) lastExecutedQuery = [[tempQueries lastObject] retain]; //perform empty query if no query is given @@ -534,7 +534,7 @@ //add query to history // if(!queriesSeparatedByDelimiter) { // TODO only add to history if no “delimiter” command was used - if(!tableReloadAfterEdting) { + if(!tableReloadAfterEditing) { [queryHistoryButton insertItemWithTitle:usedQuery atIndex:1]; int maxHistoryItems = [[prefs objectForKey:@"CustomQueryMaxHistoryItems"] intValue]; @@ -549,7 +549,7 @@ } // Error checking - if ( [errors length] ) { + if ( [errors length] && !queryIsTableSorter ) { // set the error text [errorText setStringValue:errors]; // select the line x of the first error if error message contains "at line x" @@ -590,6 +590,9 @@ } + } else if ( [errors length] && queryIsTableSorter ) { + [errorText setStringValue:NSLocalizedString(@"Couldn't sort column.", @"text shown if an error occured while sorting the result table")]; + NSBeep(); } else { [errorText setStringValue:NSLocalizedString(@"There were no errors.", @"text shown when query was successfull")]; } @@ -664,7 +667,7 @@ // Add columns corresponding to the query result theColumns = [theResult fetchFieldNames]; - if(!tableReloadAfterEdting) { + if(!tableReloadAfterEditing) { for ( i = 0 ; i < [theResult numOfFields] ; i++) { theCol = [[NSTableColumn alloc] initWithIdentifier:[NSArrayObjectAtIndex(cqColumnDefinition,i) objectForKey:@"datacolumnindex"]]; [theCol setResizingMask:NSTableColumnUserResizingMask]; @@ -1398,7 +1401,7 @@ } // On success reload table data by executing the last query - tableReloadAfterEdting = YES; + tableReloadAfterEditing = YES; [self performQueries:[NSArray arrayWithObject:lastExecutedQuery]]; } else { @@ -1429,7 +1432,7 @@ if (sortField) [sortField release]; sortField = [[NSNumber alloc] initWithInt:[[tableColumn identifier] intValue]]; - + // Order by the column position number to avoid ambiguous name errors NSString* newOrder = [NSString stringWithFormat:@" ORDER BY %i %@ ", [[tableColumn identifier] intValue]+1, (isDesc)?@"DESC":@"ASC"]; @@ -1441,9 +1444,13 @@ else [queryString appendFormat:@" %@", newOrder]; - tableReloadAfterEdting = YES; + tableReloadAfterEditing = YES; + queryIsTableSorter = YES; [self performQueries:[NSArray arrayWithObject:queryString]]; - + queryIsTableSorter = NO; + + if(![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) return; + //sets highlight and indicatorImage [customQueryView setHighlightedTableColumn:tableColumn]; if ( isDesc ) -- cgit v1.2.3