aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDataImport.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-10-25 20:22:23 +0000
committerrowanbeentje <rowan@beent.je>2010-10-25 20:22:23 +0000
commitb0ba61dfc7d3adda17c312cbc5f07afb0f527454 (patch)
treea664326d0eca2d5e61f242c788806356cba8635b /Source/SPDataImport.m
parent2ece071d16072cf819e5ad89cdf0b5d14979ff02 (diff)
downloadsequelpro-b0ba61dfc7d3adda17c312cbc5f07afb0f527454.tar.gz
sequelpro-b0ba61dfc7d3adda17c312cbc5f07afb0f527454.tar.bz2
sequelpro-b0ba61dfc7d3adda17c312cbc5f07afb0f527454.zip
- 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
Diffstat (limited to 'Source/SPDataImport.m')
-rw-r--r--Source/SPDataImport.m17
1 files changed, 14 insertions, 3 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];