diff options
author | Bibiko <bibiko@eva.mpg.de> | 2011-01-09 23:59:38 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2011-01-09 23:59:38 +0000 |
commit | a445243c4c9140556b66c8d529c1531011774911 (patch) | |
tree | 38f15dd2cca592a0b71a50b93cea1bd3b65bd899 | |
parent | d33b67301a41a9855271b41170f417de73616d11 (diff) | |
download | sequelpro-a445243c4c9140556b66c8d529c1531011774911.tar.gz sequelpro-a445243c4c9140556b66c8d529c1531011774911.tar.bz2 sequelpro-a445243c4c9140556b66c8d529c1531011774911.zip |
• fixed bug for setting SP_BUNDLE_INPUT_TABLE_METADATA if user changed column order in Content and Query Editor table
-rw-r--r-- | Source/SPCopyTable.m | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index cb7e08c5..973dfecb 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -1225,11 +1225,21 @@ NSInteger kBlobAsImageFile = 4; return; } + + // Create an array of table column mappings for fast iteration + NSArray *columns = [self tableColumns]; + NSUInteger numColumns = [columns count]; + NSUInteger *columnMappings = malloc(numColumns * sizeof(NSUInteger)); + NSInteger c; + for ( c = 0; c < numColumns; c++ ) + columnMappings[c] = [[NSArrayObjectAtIndex(columns, c) identifier] unsignedIntValue]; + NSMutableString *tableMetaData = [NSMutableString string]; if([[self delegate] isKindOfClass:[SPCustomQuery class]]) { [env setObject:@"query" forKey:SPBundleShellVariableDataTableSource]; NSArray *defs = [[self delegate] dataColumnDefinitions]; - for(NSDictionary* col in defs) { + for( c = 0; c < numColumns; c++ ) { + NSDictionary *col = NSArrayObjectAtIndex(defs, columnMappings[c]); [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"type"]]; [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"typegrouping"]]; [tableMetaData appendFormat:@"%@\t", ([col objectForKey:@"char_length"]) ? : @""]; @@ -1242,7 +1252,8 @@ NSInteger kBlobAsImageFile = 4; else if([[self delegate] isKindOfClass:[SPTableContent class]]) { [env setObject:@"content" forKey:SPBundleShellVariableDataTableSource]; NSArray *defs = [[self delegate] dataColumnDefinitions]; - for(NSDictionary* col in defs) { + for( c = 0; c < numColumns; c++ ) { + NSDictionary *col = NSArrayObjectAtIndex(defs, columnMappings[c]); [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"type"]]; [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"typegrouping"]]; [tableMetaData appendFormat:@"%@\t", ([col objectForKey:@"length"]) ? : @""]; |