From b0ba61dfc7d3adda17c312cbc5f07afb0f527454 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 25 Oct 2010 20:22:23 +0000 Subject: - Fix incorrect quoting of BLOB fields on SQL exports - Use indeterminate progress bars when importing BZIPped SQL files - Support .tsv as a CSV extension, and automatically choose the field delineator based on .csv/.tsv extension --- Source/SPDataImport.m | 17 ++++++++++++++--- Source/SPSQLExporter.m | 5 +++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m index 8a8f9d64..dc22cb0f 100644 --- a/Source/SPDataImport.m +++ b/Source/SPDataImport.m @@ -384,15 +384,19 @@ fileTotalLength = [[[[NSFileManager defaultManager] attributesOfItemAtPath:filename error:NULL] objectForKey:NSFileSize] longLongValue]; if (!fileTotalLength) fileTotalLength = 1; + // If importing a bzipped file, use indeterminate progress bars as no progress is available + BOOL useIndeterminate = NO; + if ([sqlFileHandle compressionFormat] == SPBzip2Compression) useIndeterminate = YES; + // Reset progress interface [errorsView setString:@""]; [[singleProgressTitle onMainThread] setStringValue:NSLocalizedString(@"Importing SQL", @"text showing that the application is importing SQL")]; [[singleProgressText onMainThread] setStringValue:NSLocalizedString(@"Reading...", @"text showing that app is reading dump")]; - [[singleProgressBar onMainThread] setIndeterminate:NO]; + [[singleProgressBar onMainThread] setIndeterminate:useIndeterminate]; [[singleProgressBar onMainThread] setMaxValue:fileTotalLength]; [[singleProgressBar onMainThread] setUsesThreadedAnimation:YES]; [[singleProgressBar onMainThread] startAnimation:self]; - + // Open the progress sheet [[NSApp onMainThread] beginSheet:singleProgressSheet modalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self didEndSelector:nil contextInfo:nil]; [[singleProgressSheet onMainThread] makeKeyWindow]; @@ -1467,10 +1471,17 @@ if ([pathExtension isEqualToString:@"SQL"]) { [importFormatPopup selectItemWithTitle:@"SQL"]; [self changeFormat:self]; - } else if ([pathExtension isEqualToString:@"CSV"]) { + } else if ([pathExtension isEqualToString:@"CSV"] || [pathExtension isEqualToString:@"TSV"]) { [importFormatPopup selectItemWithTitle:@"CSV"]; [self changeFormat:self]; + // Set the cell delineator based on extension + if ([pathExtension isEqualToString:@"CSV"]) { + [importFieldsTerminatedField setStringValue:@","]; + } else if ([pathExtension isEqualToString:@"TSV"]) { + [importFieldsTerminatedField setStringValue:@"\\t"]; + } + // Try to detect the line endings using "file" NSTask *fileTask = [[NSTask alloc] init]; NSPipe *filePipe = [[NSPipe alloc] init]; diff --git a/Source/SPSQLExporter.m b/Source/SPSQLExporter.m index 1374ccda..d999cc2b 100644 --- a/Source/SPSQLExporter.m +++ b/Source/SPSQLExporter.m @@ -396,10 +396,11 @@ [sqlString appendString:data]; [data release]; + + [sqlString appendString:@"'"]; } - - [sqlString appendString:@"'"]; } + // GEOMETRY data types directly as hex data else if ([object isKindOfClass:[MCPGeometryData class]]) { [sqlString appendFormat:@"X'%@'", [connection prepareBinaryData:[object data]]]; -- cgit v1.2.3