diff options
author | avenjamin <avenjamin@gmail.com> | 2009-03-27 12:01:58 +0000 |
---|---|---|
committer | avenjamin <avenjamin@gmail.com> | 2009-03-27 12:01:58 +0000 |
commit | d28c1f911f532bdb83cd0da2f4f7048c5e029a82 (patch) | |
tree | aca597bc25db74ccb742f411896ceffc2fbaac04 | |
parent | a3689bfe638e7141cfd76980fa33010446e06e0d (diff) | |
download | sequelpro-d28c1f911f532bdb83cd0da2f4f7048c5e029a82.tar.gz sequelpro-d28c1f911f532bdb83cd0da2f4f7048c5e029a82.tar.bz2 sequelpro-d28c1f911f532bdb83cd0da2f4f7048c5e029a82.zip |
Fixed bug where exporting current table would use the field terminator, enclosure, escape and line ending characters from the "export multiple tables" dialog instead.
-rw-r--r-- | Source/TableDump.h | 3 | ||||
-rw-r--r-- | Source/TableDump.m | 38 |
2 files changed, 27 insertions, 14 deletions
diff --git a/Source/TableDump.h b/Source/TableDump.h index 3f89ab68..4575444b 100644 --- a/Source/TableDump.h +++ b/Source/TableDump.h @@ -132,7 +132,8 @@ toFileHandle:(NSFileHandle *)fileHandle tableName:(NSString *)table withHeader:(BOOL)header silently:(BOOL)silently; - (NSString *)htmlEscapeString:(NSString *)string; -- (BOOL)exportTables:(NSArray *)selectedTables toFileHandle:(NSFileHandle *)fileHandle usingFormat:(NSString *)type; + +- (BOOL)exportTables:(NSArray *)selectedTables toFileHandle:(NSFileHandle *)fileHandle usingFormat:(NSString *)type usingMulti:(BOOL)multi; - (BOOL)exportSelectedTablesToFileHandle:(NSFileHandle *)fileHandle usingFormat:(NSString *)type; //additional methods diff --git a/Source/TableDump.m b/Source/TableDump.m index 0f845921..c1532b23 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -244,11 +244,11 @@ // Export the full resultset for the currently selected table to a file in CSV format } else if ( [contextInfo isEqualToString:@"exportTableContentAsCSV"] ) { - success = [self exportTables:[NSArray arrayWithObject:[tableDocumentInstance table]] toFileHandle:fileHandle usingFormat:@"csv"]; + success = [self exportTables:[NSArray arrayWithObject:[tableDocumentInstance table]] toFileHandle:fileHandle usingFormat:@"csv" usingMulti:NO]; // Export the full resultset for the currently selected table to a file in XML format } else if ( [contextInfo isEqualToString:@"exportTableContentAsXML"] ) { - success = [self exportTables:[NSArray arrayWithObject:[tableDocumentInstance table]] toFileHandle:fileHandle usingFormat:@"xml"]; + success = [self exportTables:[NSArray arrayWithObject:[tableDocumentInstance table]] toFileHandle:fileHandle usingFormat:@"xml" usingMulti:NO]; // Export the current "browse" view to a file in CSV format } else if ( [contextInfo isEqualToString:@"exportBrowseViewAsCSV"] ) { @@ -1497,14 +1497,14 @@ } } - return [self exportTables:selectedTables toFileHandle:fileHandle usingFormat:type]; + return [self exportTables:selectedTables toFileHandle:fileHandle usingFormat:type usingMulti:YES]; } /* Walks through the selected tables and exports them to a file handle. The export type must be "csv" for CSV format, and "xml" for XML format. */ -- (BOOL)exportTables:(NSArray *)selectedTables toFileHandle:(NSFileHandle *)fileHandle usingFormat:(NSString *)type +- (BOOL)exportTables:(NSArray *)selectedTables toFileHandle:(NSFileHandle *)fileHandle usingFormat:(NSString *)type usingMulti:(BOOL)multi { int i, j; CMMCPResult *queryResult; @@ -1611,15 +1611,27 @@ // Use the appropriate export method to write the data to file if ( [type isEqualToString:@"csv"] ) { - [self writeCsvForArray:nil orQueryResult:queryResult - toFileHandle:fileHandle - outputFieldNames:[exportMultipleFieldNamesSwitch state] - terminatedBy:[exportMultipleFieldsTerminatedField stringValue] - enclosedBy:[exportMultipleFieldsEnclosedField stringValue] - escapedBy:[exportMultipleFieldsEscapedField stringValue] - lineEnds:[exportMultipleLinesTerminatedField stringValue] - withNumericColumns:tableColumnNumericStatus - silently:YES]; + if (multi) { + [self writeCsvForArray:nil orQueryResult:queryResult + toFileHandle:fileHandle + outputFieldNames:[exportMultipleFieldNamesSwitch state] + terminatedBy:[exportMultipleFieldsTerminatedField stringValue] + enclosedBy:[exportMultipleFieldsEnclosedField stringValue] + escapedBy:[exportMultipleFieldsEscapedField stringValue] + lineEnds:[exportMultipleLinesTerminatedField stringValue] + withNumericColumns:tableColumnNumericStatus + silently:YES]; + } else { + [self writeCsvForArray:nil orQueryResult:queryResult + toFileHandle:fileHandle + outputFieldNames:[exportFieldNamesSwitch state] + terminatedBy:[exportFieldsTerminatedField stringValue] + enclosedBy:[exportFieldsEnclosedField stringValue] + escapedBy:[exportFieldsEscapedField stringValue] + lineEnds:[exportLinesTerminatedField stringValue] + withNumericColumns:tableColumnNumericStatus + silently:YES]; + } // Add a spacer to the file [fileHandle writeData:[[NSString stringWithFormat:@"%@%@%@", csvLineEnd, csvLineEnd, csvLineEnd] dataUsingEncoding:connectionEncoding]]; |