From 8e22ba45ee2376ebc050332e04081693d60968bc Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Tue, 29 May 2012 23:40:24 +0000 Subject: - When creating tables as a result of CSV imports into a new table, correctly build the column syntax if the last field(s) are set not to import, addressing Issue #1358. --- Source/SPFieldMapperController.m | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Source/SPFieldMapperController.m') diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index 374bd3dd..caa83f3e 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -447,13 +447,17 @@ static NSString *SPTableViewSqlColumnID = @"sql"; [createString appendFormat:@"CREATE TABLE %@ (\n", [[newTableNameTextField stringValue] backtickQuotedString]]; NSInteger columnIndex = 0; NSInteger numberOfColumns = [fieldMappingTableColumnNames count]; - for(columnIndex = 0; columnIndex < numberOfColumns; columnIndex++) { - // add to the new table only those fields which are markes as "Do Import" - if([fieldMappingOperatorArray objectAtIndex:columnIndex] == doImport) { - [createString appendFormat:@"\t%@ %@", [[fieldMappingTableColumnNames objectAtIndex:columnIndex] backtickQuotedString], [fieldMappingTableTypes objectAtIndex:columnIndex]]; - if(columnIndex < numberOfColumns-1) [createString appendString:@", \n"]; + NSMutableArray *columnDetails = [NSMutableArray array]; + for (columnIndex = 0; columnIndex < numberOfColumns; columnIndex++) { + + // Skip fields which aren't marked as imported + if ([fieldMappingOperatorArray objectAtIndex:columnIndex] != doImport) { + continue; } + + [columnDetails addObject:[NSString stringWithFormat:@"\t%@ %@", [[fieldMappingTableColumnNames objectAtIndex:columnIndex] backtickQuotedString], [fieldMappingTableTypes objectAtIndex:columnIndex]]]; } + [createString appendString:[columnDetails componentsJoinedByString:@", \n"]]; [createString appendString:@")"]; #ifndef SP_REFACTOR -- cgit v1.2.3