aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPCustomQuery.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPCustomQuery.m')
-rw-r--r--Source/SPCustomQuery.m64
1 files changed, 35 insertions, 29 deletions
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index f7f31088..8a2bc021 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -36,7 +36,9 @@
#import "SPFieldEditorController.h"
#import "SPTextAndLinkCell.h"
#import "SPTooltip.h"
+#ifndef SP_REFACTOR /* headers */
#import "SPQueryFavoriteManager.h"
+#endif
#import "SPQueryController.h"
#import "SPQueryDocumentsController.h"
#import "SPEncodingPopupAccessory.h"
@@ -269,7 +271,7 @@
// init query favorites controller
#ifndef SP_REFACTOR
[prefs synchronize];
-#endif
+
if(favoritesManager) [favoritesManager release];
favoritesManager = [[SPQueryFavoriteManager alloc] initWithDelegate:self];
@@ -279,6 +281,7 @@
modalDelegate:favoritesManager
didEndSelector:nil
contextInfo:nil];
+#endif
}
else if ([queryFavoritesButton indexOfSelectedItem] > 5) {
// Choose favorite
@@ -1484,22 +1487,28 @@
{
[tempRow addObject:[[tableColumn headerCell] stringValue]];
}
-
+
NSMutableArray *currentResult = [NSMutableArray array];
[currentResult addObject:[NSArray arrayWithArray:tempRow]];
- //add rows
- for ( i = 0 ; i < [self numberOfRowsInTableView:customQueryView] ; i++) {
+ // Add rows
+ for (i = 0; i < [self numberOfRowsInTableView:customQueryView]; i++)
+ {
[tempRow removeAllObjects];
+
NSEnumerator *enumerator = [[customQueryView tableColumns] objectEnumerator];
- while ( (tableColumn = [enumerator nextObject]) ) {
+
+ while ((tableColumn = [enumerator nextObject]))
+ {
id value = [self _resultDataItemAtRow:i columnIndex:[[tableColumn identifier] integerValue]];
[tempRow addObject:[self _convertResultDataValueToDisplayableRepresentation:value whilePreservingNULLs:includeNULLs truncateDataFields:truncate]];
}
+
[currentResult addObject:[NSArray arrayWithArray:tempRow]];
}
+
[tempRow release];
return currentResult;
@@ -1830,10 +1839,6 @@
[columnsInSpecifiedTable addObject:field];
}
- // Try to identify the field bijectively
- NSMutableString *fieldIDQueryStr = [NSMutableString string];
- [fieldIDQueryStr setString:@"WHERE ("];
-
// --- Build WHERE clause ---
dataRow = [resultData rowContentsAtIndex:rowIndex];
@@ -1858,30 +1863,26 @@
// Build up the argument
for (field in columnsToQuery) {
id aValue = [dataRow objectAtIndex:[[field objectForKey:@"datacolumnindex"] integerValue]];
-
if ([aValue isNSNull]) {
[argumentParts addObject:[NSString stringWithFormat:@"%@ IS NULL", [[field objectForKey:@"org_name"] backtickQuotedString]]];
- }
- else {
+ } else {
NSString *fieldTypeGrouping = [field objectForKey:@"typegrouping"];
-
+
// Skip blob-type fields if requested
if (!includeBlobs
- && ([fieldTypeGrouping isEqualToString:@"textdata"] ||
- [fieldTypeGrouping isEqualToString:@"blobdata"] ||
- [[field objectForKey:@"type"] isEqualToString:@"BINARY"] ||
- [[field objectForKey:@"type"] isEqualToString:@"VARBINARY"]))
+ && ([fieldTypeGrouping isEqualToString:@"textdata"]
+ || [fieldTypeGrouping isEqualToString:@"blobdata"]
+ || [[field objectForKey:@"type"] isEqualToString:@"BINARY"]
+ || [[field objectForKey:@"type"] isEqualToString:@"VARBINARY"]))
{
continue;
}
-
- if ([[field objectForKey:@"typegrouping"] isEqualToString:@"bit"]) {
+
+ // If the field is of type BIT then it needs a binary prefix
+ if ([fieldTypeGrouping isEqualToString:@"bit"]) {
[argumentParts addObject:[NSString stringWithFormat:@"%@=b'%@'", [[field objectForKey:@"org_name"] backtickQuotedString], [aValue description]]];
}
- else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"integer"]) {
- [fieldIDQueryStr appendFormat:@"%@=%@ AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [aValue description]];
- }
- else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"geometry"]) {
+ else if ([fieldTypeGrouping isEqualToString:@"geometry"]) {
[argumentParts addObject:[NSString stringWithFormat:@"%@=%@", [[field objectForKey:@"org_name"] backtickQuotedString], [mySQLConnection escapeAndQuoteData:[aValue data]]]];
}
// BLOB/TEXT data
@@ -3054,15 +3055,16 @@
{
NSString *version = nil;
if([[mySQLversion stringByReplacingOccurrencesOfString:@"." withString:@""] integerValue] < 42)
- version = @"41";
+ version = @"4.1";
else
- version = [mySQLversion stringByReplacingOccurrencesOfString:@"." withString:@""];
+ version = [NSString stringWithString:mySQLversion];
+
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:
[[NSString stringWithFormat:
SPMySQLSearchURL,
- searchString,
version,
- NSLocalizedString(@"en", @"MySQL search language code - eg in http://search.mysql.com/search?q=select&site=refman-50&lr=lang_en")]
+ NSLocalizedString(@"en", @"MySQL search language code - eg in http://search.mysql.com/search?q=select&site=refman-50&lr=lang_en"),
+ searchString]
stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]];
}
@@ -3389,7 +3391,9 @@
initWithString:([favorite objectForKey:@"tabtrigger"] && [(NSString*)[favorite objectForKey:@"tabtrigger"] length]) ? [NSString stringWithFormat:@"%@\t%@⇥", [favorite objectForKey:@"name"], [favorite objectForKey:@"tabtrigger"]] : [favorite objectForKey:@"name"]
attributes:attributes] autorelease];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""];
- [item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]];
+ if ([favorite objectForKey:@"query"]) {
+ [item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]];
+ }
[item setAttributedTitle:titleString];
[item setIndentationLevel:1];
[menu addItem:item];
@@ -3414,7 +3418,9 @@
initWithString:([favorite objectForKey:@"tabtrigger"] && [(NSString*)[favorite objectForKey:@"tabtrigger"] length]) ? [NSString stringWithFormat:@"%@\t%@⇥", [favorite objectForKey:@"name"], [favorite objectForKey:@"tabtrigger"]] : [favorite objectForKey:@"name"]
attributes:attributes] autorelease];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""];
- [item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]];
+ if ([favorite objectForKey:@"query"]) {
+ [item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]];
+ }
[item setAttributedTitle:titleString];
[item setIndentationLevel:1];
[menu addItem:item];