diff options
author | rowanbeentje <rowan@beent.je> | 2012-05-29 23:40:24 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-05-29 23:40:24 +0000 |
commit | 8e22ba45ee2376ebc050332e04081693d60968bc (patch) | |
tree | 9adcc67163b99208ec6560a5868d75b4813cc514 /Source/SPFieldMapperController.m | |
parent | f4617f63faf037ada6d313034bad2e4132bd5a9b (diff) | |
download | sequelpro-8e22ba45ee2376ebc050332e04081693d60968bc.tar.gz sequelpro-8e22ba45ee2376ebc050332e04081693d60968bc.tar.bz2 sequelpro-8e22ba45ee2376ebc050332e04081693d60968bc.zip |
- 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.
Diffstat (limited to 'Source/SPFieldMapperController.m')
-rw-r--r-- | Source/SPFieldMapperController.m | 14 |
1 files changed, 9 insertions, 5 deletions
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 |