aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableDump.m
diff options
context:
space:
mode:
authoravenjamin <avenjamin@gmail.com>2009-03-27 12:01:58 +0000
committeravenjamin <avenjamin@gmail.com>2009-03-27 12:01:58 +0000
commitd28c1f911f532bdb83cd0da2f4f7048c5e029a82 (patch)
treeaca597bc25db74ccb742f411896ceffc2fbaac04 /Source/TableDump.m
parenta3689bfe638e7141cfd76980fa33010446e06e0d (diff)
downloadsequelpro-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.
Diffstat (limited to 'Source/TableDump.m')
-rw-r--r--Source/TableDump.m38
1 files changed, 25 insertions, 13 deletions
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]];