aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CustomQuery.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CustomQuery.m')
-rw-r--r--Source/CustomQuery.m29
1 files changed, 18 insertions, 11 deletions
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 )