aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPTableContent.h2
-rw-r--r--Source/SPTableContent.m11
2 files changed, 9 insertions, 4 deletions
diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h
index 5f3aba47..a23aec65 100644
--- a/Source/SPTableContent.h
+++ b/Source/SPTableContent.h
@@ -72,7 +72,7 @@
IBOutlet NSButton *filterTableClearButton;
IBOutlet SPTextView *filterTableWhereClause;
IBOutlet id filterTableNegateCheckbox;
- IBOutlet id filterTableDistinctCheckbox;
+ IBOutlet NSMenuItem *filterTableDistinctMenuItem;
IBOutlet id filterTableLiveSearchCheckbox;
IBOutlet NSMenuItem *filterTableGearLookAllFields;
IBOutlet NSPanel *filterTableSetDefaultOperatorSheet;
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index bb7754cc..d9bd1edf 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -172,7 +172,7 @@
[contentViewPane addSubview:paginationView];
// Init Filter Table GUI
- [filterTableDistinctCheckbox setState:(filterTableDistinct) ? NSOnState : NSOffState];
+ [filterTableDistinctMenuItem setState:(filterTableDistinct) ? NSOnState : NSOffState];
[filterTableNegateCheckbox setState:(filterTableNegate) ? NSOnState : NSOffState];
[filterTableLiveSearchCheckbox setState:NSOffState];
filterTableDefaultOperator = [[self escapeFilterTableDefaultOperator:[prefs objectForKey:SPFilterTableDefaultOperator]] retain];
@@ -636,7 +636,7 @@
[[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance];
// Start construction of the query string
- queryString = [NSMutableString stringWithFormat:@"SELECT %@%@ FROM %@", (activeFilter == 1 && [self tableFilterString] && [filterTableDistinctCheckbox state] == NSOnState) ? @"DISTINCT " : @"", [self fieldListForQuery], [selectedTable backtickQuotedString]];
+ queryString = [NSMutableString stringWithFormat:@"SELECT %@%@ FROM %@", (activeFilter == 1 && [self tableFilterString] && filterTableDistinct) ? @"DISTINCT " : @"", [self fieldListForQuery], [selectedTable backtickQuotedString]];
// Add a filter string if appropriate
filterString = [self tableFilterString];
@@ -2933,6 +2933,8 @@
{
filterTableDistinct = !filterTableDistinct;
+ [filterTableDistinctMenuItem setState:(filterTableDistinct) ? NSOnState : NSOffState];
+
// If live search is set perform filtering
if([filterTableLiveSearchCheckbox state] == NSOnState)
[self filterTable:filterTableFilterButton];
@@ -4205,7 +4207,10 @@
*/
- (NSString*)escapeFilterTableDefaultOperator:(NSString*)anOperator
{
- NSMutableString *newOp = [NSMutableString string];
+
+ if(anOperator == nil) return @"";
+
+ NSMutableString *newOp = [[[NSMutableString alloc] initWithCapacity:[anOperator length]] autorelease];
[newOp setString:anOperator];
[newOp replaceOccurrencesOfRegex:@"%" withString:@"%%"];
[newOp replaceOccurrencesOfRegex:@"(?<!`)@(?!=`)" withString:@"%"];