diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMTextView.m | 2 | ||||
-rw-r--r-- | Source/SPFieldMapperController.h | 26 | ||||
-rw-r--r-- | Source/SPFieldMapperController.m | 246 | ||||
-rw-r--r-- | Source/SPQueryController.m | 2 | ||||
-rw-r--r-- | Source/TableDocument.m | 33 | ||||
-rw-r--r-- | Source/TableDump.m | 3 |
6 files changed, 236 insertions, 76 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m index 4a226ef5..d6a1e9d7 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -507,7 +507,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) BOOL caretMovedLeft = NO; // Check if caret is located after a ` - if so move caret inside - if([[self string] length] && [[self string] characterAtIndex:caretPos-1] == '`') { + if([[self string] length] && caretPos > 0 && [[self string] characterAtIndex:caretPos-1] == '`') { if([[self string] length] > caretPos && [[self string] characterAtIndex:caretPos] == '`') { ; } else { diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h index 6dc7ffe8..7db0f5c9 100644 --- a/Source/SPFieldMapperController.h +++ b/Source/SPFieldMapperController.h @@ -29,6 +29,7 @@ @interface SPFieldMapperController : NSWindowController { IBOutlet NSTableView *fieldMapperTableView; + IBOutlet id fieldMapperTableScrollView; IBOutlet NSTableView *globalValuesTableView; IBOutlet NSPopUpButton *tableTargetPopup; IBOutlet NSPathControl *fileSourcePath; @@ -39,7 +40,11 @@ IBOutlet id importFieldNamesHeaderSwitch; IBOutlet id addRemainingDataSwitch; IBOutlet id importButton; + IBOutlet id advancedBox; IBOutlet NSPopUpButton *alignByPopup; + IBOutlet id alignByPopupLabel; + IBOutlet id importMethodLabel; + IBOutlet id advancedLabel; IBOutlet NSMenuItem *matchingNameMenuItem; IBOutlet id globalValuesSheet; @@ -48,14 +53,25 @@ IBOutlet NSButton *insertNULLValueButton; IBOutlet id replaceAfterSavingCheckBox; - IBOutlet id advancedSheet; IBOutlet id ignoreCheckBox; + IBOutlet id ignoreUpdateCheckBox; IBOutlet id delayedCheckBox; + IBOutlet id delayedReplaceCheckBox; IBOutlet id onupdateCheckBox; + IBOutlet id lowPriorityCheckBox; + IBOutlet id lowPriorityReplaceCheckBox; + IBOutlet id lowPriorityUpdateCheckBox; + IBOutlet id highPriorityCheckBox; IBOutlet CMTextView *onupdateTextView; + IBOutlet id advancedButton; + IBOutlet id advancedInsertView; + IBOutlet id advancedReplaceView; + IBOutlet id advancedUpdateView; + id theDelegate; + id customQueryInstance; id fieldMappingImportArray; NSInteger fieldMappingCurrentRow; @@ -79,6 +95,7 @@ BOOL fieldMappingImportArrayIsPreview; BOOL importFieldNamesHeader; + BOOL showAdvancedView; NSNumber *lastDisabledCSVFieldcolumn; MCPConnection *mySQLConnection; @@ -86,6 +103,11 @@ NSString *sourcePath; NSUserDefaults *prefs; + + NSInteger heightOffset; + NSUInteger windowMinWidth; + NSUInteger windowMinHeigth; + } @property(retain) NSString* sourcePath; @@ -122,11 +144,11 @@ - (IBAction)removeGlobalValue:(id)sender; - (IBAction)insertNULLValue:(id)sender; - (IBAction)closeGlobalValuesSheet:(id)sender; -- (IBAction)closeAdvancedSheet:(id)sender; - (IBAction)advancedCheckboxValidation:(id)sender; // Others +- (void)resizeWindowByHeightDelta:(NSInteger)delta; - (void)matchHeaderNames; - (void)setupFieldMappingArray; - (void)updateFieldMappingButtonCell; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index e6fafe1b..1760d239 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -80,7 +80,11 @@ { // Set source path - [fileSourcePath setURL:[NSURL URLWithString:sourcePath]]; + [fileSourcePath setURL:[NSURL fileURLWithPath:sourcePath]]; + [fileSourcePath setDoubleAction:@selector(goBackToFileChooser:)]; + [onupdateTextView setDelegate:theDelegate]; + windowMinWidth = [[self window] minSize].width; + windowMinHeigth = [[self window] minSize].height; // Init table target popup menu [tableTargetPopup removeAllItems]; @@ -97,9 +101,27 @@ } [importFieldNamesHeaderSwitch setState:importFieldNamesHeader]; - [addRemainingDataSwitch setHidden:YES]; - [addRemainingDataSwitch setState:NSOffState]; - + + [addRemainingDataSwitch setState:NO]; + [ignoreCheckBox setState:NO]; + [ignoreUpdateCheckBox setState:NO]; + [delayedCheckBox setState:NO]; + [delayedReplaceCheckBox setState:NO]; + [onupdateCheckBox setState:NO]; + [lowPriorityCheckBox setState:NO]; + [lowPriorityReplaceCheckBox setState:NO]; + [lowPriorityUpdateCheckBox setState:NO]; + [highPriorityCheckBox setState:NO]; + + [advancedButton setState:NSOffState]; + [advancedBox setHidden:YES]; + + showAdvancedView = NO; + heightOffset = 0; + [advancedReplaceView setHidden:YES]; + [advancedUpdateView setHidden:YES]; + [advancedInsertView setHidden:YES]; + [self changeHasHeaderCheckbox:self]; [self changeTableTarget:self]; [[self window] makeFirstResponder:fieldMapperTableView]; @@ -203,18 +225,25 @@ - (NSString*)importHeaderString { if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"INSERT"]) { - return [NSString stringWithFormat:@"INSERT %@%@INTO ", + return [NSString stringWithFormat:@"INSERT %@%@%@%@INTO ", + ([lowPriorityCheckBox state] == NSOnState) ? @"LOW_PRIORITY " : @"", ([delayedCheckBox state] == NSOnState) ? @"DELAYED " : @"", + ([highPriorityCheckBox state] == NSOnState) ? @"HIGH_PRIORITY " : @"", ([ignoreCheckBox state] == NSOnState) ? @"IGNORE " : @"" ]; } else if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"REPLACE"]) { - return [NSString stringWithFormat:@"REPLACE %@INTO ", - ([delayedCheckBox state] == NSOnState) ? @"DELAYED " : @"" + return [NSString stringWithFormat:@"REPLACE %@%@INTO ", + ([lowPriorityReplaceCheckBox state] == NSOnState) ? @"LOW_PRIORITY " : @"", + ([delayedReplaceCheckBox state] == NSOnState) ? @"DELAYED " : @"" ]; } else if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"UPDATE"]) { - return [NSString stringWithFormat:@"UPDATE %@ SET ", [[self selectedTableTarget] backtickQuotedString]]; + return [NSString stringWithFormat:@"UPDATE %@%@%@ SET ", + ([lowPriorityUpdateCheckBox state] == NSOnState) ? @"LOW_PRIORITY " : @"", + ([ignoreUpdateCheckBox state] == NSOnState) ? @"IGNORE " : @"", + [[self selectedTableTarget] backtickQuotedString] + ]; } return @""; } @@ -232,6 +261,11 @@ - (IBAction)closeSheet:(id)sender { + [advancedReplaceView setHidden:YES]; + [advancedUpdateView setHidden:YES]; + [advancedInsertView setHidden:YES]; + [advancedBox setHidden:YES]; + [self resizeWindowByHeightDelta:0]; [NSApp endSheet:[self window] returnCode:[sender tag]]; } @@ -310,6 +344,15 @@ // Disable Import button if no fields are available [importButton setEnabled:([fieldMappingTableColumnNames count] > 0)]; + // Disable UPDATE import method if target table has less than 2 fields + // and fall back to INSERT if UPDATE was selected + if([fieldMappingTableColumnNames count] > 1) { + [[importMethodPopup itemWithTitle:@"UPDATE"] setEnabled:YES]; + } else { + [[importMethodPopup itemWithTitle:@"UPDATE"] setEnabled:NO]; + if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"UPDATE"]) + [importMethodPopup selectItemWithTitle:@"INSERT"]; + } [self updateFieldNameAlignment]; @@ -321,6 +364,46 @@ { NSInteger i; + [onupdateTextView setBackgroundColor:[NSColor lightGrayColor]]; + [onupdateTextView setEditable:NO]; + [ignoreCheckBox setState:NO]; + [ignoreUpdateCheckBox setState:NO]; + [delayedCheckBox setState:NO]; + [delayedReplaceCheckBox setState:NO]; + [onupdateCheckBox setState:NO]; + [lowPriorityCheckBox setState:NO]; + [lowPriorityReplaceCheckBox setState:NO]; + [lowPriorityUpdateCheckBox setState:NO]; + [highPriorityCheckBox setState:NO]; + + [advancedReplaceView setHidden:YES]; + [advancedUpdateView setHidden:YES]; + [advancedInsertView setHidden:YES]; + + if(showAdvancedView) { + [advancedBox setHidden:NO]; + if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"UPDATE"]) { + [self resizeWindowByHeightDelta:[advancedUpdateView frame].size.height-10]; + [advancedUpdateView setHidden:NO]; + [advancedInsertView setHidden:YES]; + [advancedReplaceView setHidden:YES]; + } + else if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"INSERT"]) { + [self resizeWindowByHeightDelta:[advancedInsertView frame].size.height-20]; + [advancedInsertView setHidden:NO]; + [advancedUpdateView setHidden:YES]; + [advancedReplaceView setHidden:YES]; + } + else if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"REPLACE"]) { + [self resizeWindowByHeightDelta:[advancedReplaceView frame].size.height-10]; + [advancedReplaceView setHidden:NO]; + [advancedUpdateView setHidden:YES]; + [advancedInsertView setHidden:YES]; + } + } else { + [advancedBox setHidden:YES]; + } + // If operator is set to = for UPDATE method replace it by doNotImport if(![[importMethodPopup titleOfSelectedItem] isEqualToString:@"UPDATE"]) { [advancedButton setEnabled:YES]; @@ -331,8 +414,7 @@ } } } else { - [advancedButton setEnabled:NO]; - [addRemainingDataSwitch setHidden:NO]; + [advancedButton setEnabled:YES]; [addRemainingDataSwitch setEnabled:NO]; // TODO HansJB } @@ -417,10 +499,6 @@ [self addGlobalValue:nil]; } -// TDOD this won't be called - WHY? ask HansJB -// - (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)rect { -// return NSMakeRect(300,300,50,10); -// } - (IBAction)addGlobalValue:(id)sender { [fieldMappingGlobalValues addObject:@""]; @@ -493,63 +571,123 @@ - (IBAction)openAdvancedSheet:(id)sender { - - if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"REPLACE"]) { - [ignoreCheckBox setEnabled:NO]; - [onupdateCheckBox setEnabled:NO]; - [delayedCheckBox setEnabled:YES]; - [onupdateTextView setBackgroundColor:[NSColor lightGrayColor]]; - [onupdateTextView setEditable:NO]; - } - else if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"INSERT"]) { - [ignoreCheckBox setEnabled:YES]; - [onupdateCheckBox setEnabled:([delayedCheckBox state] == NSOnState) ? NO : YES]; - [delayedCheckBox setEnabled:([onupdateCheckBox state] == NSOnState) ? NO : YES]; - if([onupdateCheckBox state] == NSOffState) { - [onupdateTextView setEditable:NO]; - [onupdateTextView setBackgroundColor:[NSColor lightGrayColor]]; - } else { - [onupdateTextView setEditable:YES]; - [onupdateTextView setBackgroundColor:[NSColor whiteColor]]; - } + showAdvancedView = !showAdvancedView; + if(showAdvancedView) { + [self changeImportMethod:nil]; + } else { + [advancedBox setHidden:YES]; + [advancedReplaceView setHidden:YES]; + [advancedUpdateView setHidden:YES]; + [advancedInsertView setHidden:YES]; + [self resizeWindowByHeightDelta:0]; } - - [advancedSheet makeFirstResponder:ignoreCheckBox]; - - [NSApp beginSheet:advancedSheet - modalForWindow:[self window] - modalDelegate:self - didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:nil]; -} - -- (IBAction)closeAdvancedSheet:(id)sender -{ - [NSApp endSheet:advancedSheet returnCode:[sender tag]]; } - (IBAction)advancedCheckboxValidation:(id)sender { - if([delayedCheckBox state] == NSOnState) - [onupdateCheckBox setState:NO]; - if([onupdateCheckBox state] == NSOnState) { + if(sender == lowPriorityReplaceCheckBox && [lowPriorityReplaceCheckBox state] == NSOnState) { + [delayedReplaceCheckBox setState:NO]; + return; + } + if(sender == delayedReplaceCheckBox && [delayedReplaceCheckBox state] == NSOnState) { + [lowPriorityReplaceCheckBox setState:NO]; + return; + } + + if(sender == lowPriorityCheckBox && [lowPriorityCheckBox state] == NSOnState) { + [highPriorityCheckBox setState:NO]; + [delayedCheckBox setState:NO]; + [onupdateCheckBox setEnabled:YES]; + } + if(sender == highPriorityCheckBox && [highPriorityCheckBox state] == NSOnState) { + [lowPriorityCheckBox setState:NO]; [delayedCheckBox setState:NO]; + [onupdateCheckBox setEnabled:YES]; + } + if(sender == delayedCheckBox) { + if([delayedCheckBox state] == NSOnState) { + [lowPriorityCheckBox setState:NO]; + [highPriorityCheckBox setState:NO]; + [onupdateCheckBox setState:NO]; + [onupdateCheckBox setEnabled:NO]; + } else { + [onupdateCheckBox setEnabled:YES]; + } + } + + if(sender == onupdateCheckBox && [onupdateCheckBox state] == NSOnState) { [onupdateTextView setBackgroundColor:[NSColor whiteColor]]; [onupdateTextView setEditable:YES]; - [advancedSheet makeFirstResponder:onupdateTextView]; - } else { + [[self window] makeFirstResponder:onupdateTextView]; + } + if([onupdateCheckBox state] == NSOffState) { [onupdateTextView setBackgroundColor:[NSColor lightGrayColor]]; [onupdateTextView setEditable:NO]; } - - [onupdateCheckBox setEnabled:([delayedCheckBox state] == NSOnState) ? NO : YES]; - [delayedCheckBox setEnabled:([onupdateCheckBox state] == NSOnState) ? NO : YES]; - } #pragma mark - #pragma mark Others +- (void)resizeWindowByHeightDelta:(NSInteger)delta +{ + NSUInteger tableMask = [fieldMapperTableScrollView autoresizingMask]; + NSUInteger headerSwitchMask = [importFieldNamesHeaderSwitch autoresizingMask]; + NSUInteger alignPopupMask = [alignByPopup autoresizingMask]; + NSUInteger alignPopupLabelMask = [alignByPopupLabel autoresizingMask]; + NSUInteger importMethodLabelMask = [importMethodLabel autoresizingMask]; + NSUInteger importMethodMask = [importMethodPopup autoresizingMask]; + NSUInteger advancedButtonMask = [advancedButton autoresizingMask]; + NSUInteger advancedLabelMask = [advancedLabel autoresizingMask]; + NSUInteger insertViewMask = [advancedInsertView autoresizingMask]; + NSUInteger updateViewMask = [advancedUpdateView autoresizingMask]; + NSUInteger replaceViewMask = [advancedReplaceView autoresizingMask]; + + NSRect frame = [[self window] frame]; + if(frame.size.height>600 && delta > heightOffset) { + frame.origin.y += [advancedInsertView frame].size.height; + frame.size.height -= [advancedInsertView frame].size.height; + [[self window] setFrame:frame display:YES animate:YES]; + } + + [fieldMapperTableScrollView setAutoresizingMask:NSViewNotSizable|NSViewMinYMargin]; + [importFieldNamesHeaderSwitch setAutoresizingMask:NSViewNotSizable|NSViewMinYMargin]; + [alignByPopup setAutoresizingMask:NSViewNotSizable|NSViewMinYMargin]; + [alignByPopupLabel setAutoresizingMask:NSViewNotSizable|NSViewMinYMargin]; + [importMethodLabel setAutoresizingMask:NSViewNotSizable|NSViewMinYMargin]; + [importMethodPopup setAutoresizingMask:NSViewNotSizable|NSViewMinYMargin]; + [advancedButton setAutoresizingMask:NSViewNotSizable|NSViewMinYMargin]; + [advancedLabel setAutoresizingMask:NSViewNotSizable|NSViewMinYMargin]; + [advancedInsertView setAutoresizingMask:NSViewNotSizable|NSViewMinYMargin]; + [advancedUpdateView setAutoresizingMask:NSViewNotSizable|NSViewMinYMargin]; + [advancedReplaceView setAutoresizingMask:NSViewNotSizable|NSViewMinYMargin]; + [advancedBox setAutoresizingMask:NSViewNotSizable|NSViewWidthSizable|NSViewHeightSizable|NSViewMaxXMargin|NSViewMinXMargin]; + + NSInteger newMinHeight = (windowMinHeigth-heightOffset+delta < windowMinHeigth) ? windowMinHeigth : windowMinHeigth-heightOffset+delta; + [[self window] setMinSize:NSMakeSize(windowMinWidth, newMinHeight)]; + frame.origin.y += heightOffset; + frame.size.height -= heightOffset; + heightOffset = delta; + frame.origin.y -= heightOffset; + frame.size.height += heightOffset; + [[self window] setFrame:frame display:YES animate:YES]; + + [fieldMapperTableScrollView setAutoresizingMask:tableMask]; + [importFieldNamesHeaderSwitch setAutoresizingMask:headerSwitchMask]; + [alignByPopup setAutoresizingMask:alignPopupMask]; + [alignByPopupLabel setAutoresizingMask:alignPopupLabelMask]; + [importMethodLabel setAutoresizingMask:importMethodLabelMask]; + [importMethodPopup setAutoresizingMask:importMethodMask]; + [advancedButton setAutoresizingMask:advancedButtonMask]; + [advancedLabel setAutoresizingMask:advancedLabelMask]; + [advancedReplaceView setAutoresizingMask:replaceViewMask]; + [advancedUpdateView setAutoresizingMask:updateViewMask]; + [advancedInsertView setAutoresizingMask:insertViewMask]; + [advancedBox setAutoresizingMask:NSViewNotSizable|NSViewWidthSizable|NSViewMaxYMargin|NSViewMaxXMargin|NSViewMinXMargin]; + +} + - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { [sheet orderOut:self]; diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index 8b1b6c8e..911923bd 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -620,7 +620,7 @@ static SPQueryController *sharedQueryController = nil; // Save history items coming from each Untitled document in the global Preferences successively // regardingless of the source document. - if(![[fileURL absoluteString] hasPrefix:@"/"]) { + if(![fileURL isFileURL]) { // Remove all duplicates by using a NSPopUpButton NSPopUpButton *uniquifier = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(0,0,0,0) pullsDown:YES]; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 69e3a337..689ee253 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -500,7 +500,7 @@ [spfDocData setObject:[NSNumber numberWithBool:YES] forKey:@"include_session"]; } - [self setFileURL:[NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; + [self setFileURL:[NSURL fileURLWithPath:path]]; [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:[NSURL fileURLWithPath:path]]; if([spf objectForKey:SPQueryFavorites]) @@ -2426,7 +2426,7 @@ [[NSDocumentController sharedDocumentController] addDocument:newTableDocument]; [newTableDocument makeWindowControllers]; [newTableDocument showWindows]; - [newTableDocument initWithConnectionFile:[[[self fileURL] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + [newTableDocument initWithConnectionFile:[[self fileURL] path]]; } } @@ -2457,8 +2457,7 @@ */ - (BOOL)isUntitled { - // Check whether fileURL path begins with a '/' - return ([[[self fileURL] absoluteString] hasPrefix:@"/"]) ? NO : YES; + return ([[self fileURL] isFileURL]) ? NO : YES; } #pragma mark - @@ -2553,9 +2552,9 @@ - (void)applicationWillTerminate:(NSNotification *)notification { // Auto-save preferences to spf file based connection - if([self fileURL] && [[[self fileURL] absoluteString] length] && ![self isUntitled]) + if([self fileURL] && [[[self fileURL] path] length] && ![self isUntitled]) if(_isConnected && ![self saveDocumentWithFilePath:nil inBackground:YES onlyPreferences:YES]) { - NSLog(@"Preference data for file ‘%@’ could not be saved.", [[[self fileURL] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]); + NSLog(@"Preference data for file ‘%@’ could not be saved.", [[self fileURL] path]); NSBeep(); } @@ -2609,7 +2608,7 @@ // If Save was invoked check for fileURL and Untitled docs and save the spf file without save panel // otherwise ask for file name - if(sender != nil && [sender tag] == 1004 && [[[self fileURL] absoluteString] length] && ![self isUntitled]) { + if(sender != nil && [sender tag] == 1004 && [[[self fileURL] path] length] && ![self isUntitled]) { [self saveDocumentWithFilePath:nil inBackground:YES onlyPreferences:NO]; return; } @@ -2646,7 +2645,7 @@ [panel setAccessoryView:saveConnectionAccessory]; // Set file name - if([[[self fileURL] absoluteString] length]) + if([[[self fileURL] path] length]) filename = [self displayName]; else filename = [NSString stringWithFormat:@"%@", [self name]]; @@ -2742,7 +2741,7 @@ NSMutableDictionary *spfDocData_temp = [NSMutableDictionary dictionary]; if(fileName == nil) - fileName = [[[self fileURL] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + fileName = [[self fileURL] path]; //[[[self fileURL] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; // Store save panel settings or take them from spfDocData if(!saveInBackground) { @@ -2764,7 +2763,7 @@ if(saveOnlyPreferences) { // Check URL for safety reasons - if(![[[self fileURL] absoluteString] length] || [self isUntitled]) { + if(![[[self fileURL] path] length] || [self isUntitled]) { NSLog(@"Couldn't save data. No file URL found!"); NSBeep(); return NO; @@ -3010,9 +3009,9 @@ [preferences setObject:[spfdata objectForKey:SPQueryHistory] forKey:SPQueryHistory]; [preferences setObject:[spfdata objectForKey:SPQueryFavorites] forKey:SPQueryFavorites]; [preferences setObject:[spfdata objectForKey:SPContentFilters] forKey:SPContentFilters]; - [[SPQueryController sharedQueryController] registerDocumentWithFileURL:[NSURL URLWithString:[fileName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] andContextInfo:preferences]; + [[SPQueryController sharedQueryController] registerDocumentWithFileURL:[NSURL fileURLWithPath:fileName] andContextInfo:preferences]; - [self setFileURL:[NSURL URLWithString:[fileName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; + [self setFileURL:[NSURL fileURLWithPath:fileName]]; [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:[NSURL fileURLWithPath:fileName]]; [tableWindow setTitle:[self displaySPName]]; @@ -3687,7 +3686,7 @@ if ( ![tablesListInstance selectionShouldChangeInTableView:nil] ) return NO; // Auto-save spf file based connection and return whether the save was successful - if([self fileURL] && [[[self fileURL] absoluteString] length] && ![self isUntitled]) { + if([self fileURL] && [[[self fileURL] path] length] && ![self isUntitled]) { BOOL isSaved = [self saveDocumentWithFilePath:nil inBackground:YES onlyPreferences:YES]; if(isSaved) [[SPQueryController sharedQueryController] removeRegisteredDocumentWithFileURL:[self fileURL]]; @@ -3736,7 +3735,7 @@ */ - (BOOL)isDocumentEdited { - return ([self fileURL] && [[[self fileURL] absoluteString] length] && [self isUntitled] && ([[[SPQueryController sharedQueryController] favoritesForFileURL:[self fileURL]] count] + return ([self fileURL] && [[[self fileURL] path] length] && [self isUntitled] && ([[[SPQueryController sharedQueryController] favoritesForFileURL:[self fileURL]] count] || [[[[SPQueryController sharedQueryController] contentFilterForFileURL:[self fileURL]] objectForKey:@"number"] count] || [[[[SPQueryController sharedQueryController] contentFilterForFileURL:[self fileURL]] objectForKey:@"date"] count] || [[[[SPQueryController sharedQueryController] contentFilterForFileURL:[self fileURL]] objectForKey:@"string"] count]) @@ -3750,12 +3749,12 @@ { if (!_isConnected) { return [NSString stringWithFormat:@"%@%@", - ([[[self fileURL] absoluteString] length] && ![self isUntitled]) ? [NSString stringWithFormat:@"%@ — ",[[[[self fileURL] absoluteString] lastPathComponent] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] : @"", @"Sequel Pro"]; + ([[[self fileURL] path] length] && ![self isUntitled]) ? [NSString stringWithFormat:@"%@ — ",[[[self fileURL] path] lastPathComponent]] : @"", @"Sequel Pro"]; } return [NSString stringWithFormat:@"%@(MySQL %@) %@%@%@", - ([[[self fileURL] absoluteString] length] && ![self isUntitled]) ? [NSString stringWithFormat:@"%@ — ",[self displayName]] : @"", + ([[[self fileURL] path] length] && ![self isUntitled]) ? [NSString stringWithFormat:@"%@ — ",[self displayName]] : @"", mySQLVersion, [self name], ([self database]?[NSString stringWithFormat:@"/%@",[self database]]:@""), @@ -3767,7 +3766,7 @@ - (NSString *)displayName { if(!_isConnected) return [self displaySPName]; - return [[[[self fileURL] absoluteString] lastPathComponent] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + return [[[self fileURL] path] lastPathComponent]; } #pragma mark - diff --git a/Source/TableDump.m b/Source/TableDump.m index 4ee19c57..222e9715 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -990,7 +990,7 @@ query = [[NSMutableString alloc] initWithString:insertBaseString]; for (i = 0; i < csvRowsPerQuery && i < [parsedRows count]; i++) { if (i > 0) [query appendString:@",\n"]; - [query appendString:[self mappedValueStringForRowArray:[parsedRows objectAtIndex:i]]]; + [query appendString:[[self mappedValueStringForRowArray:[parsedRows objectAtIndex:i]] description]]; csvRowsThisQuery++; if ([query length] > 250000) break; } @@ -1004,6 +1004,7 @@ } else { for (i = 0; i < [parsedRows count]; i++) { if (progressCancelled) break; + query = [[NSMutableString alloc] initWithString:insertBaseString]; [query appendString:[self mappedUpdateSetStatementStringForRowArray:[parsedRows objectAtIndex:i]]]; |