aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPCopyTable.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2011-01-11 08:37:15 +0000
committerBibiko <bibiko@eva.mpg.de>2011-01-11 08:37:15 +0000
commit15100feadc549801496c6d076931ba9b765ea069 (patch)
treeac4d391a08d401275adf813d62b9a297084a6240 /Source/SPCopyTable.m
parent1da136ca968282821f61695eae4746f6c802c046 (diff)
downloadsequelpro-15100feadc549801496c6d076931ba9b765ea069.tar.gz
sequelpro-15100feadc549801496c6d076931ba9b765ea069.tar.bz2
sequelpro-15100feadc549801496c6d076931ba9b765ea069.zip
• improved error handling while writing SP_BUNDLE_TABLE_META_DATA esp. while switching databases
Diffstat (limited to 'Source/SPCopyTable.m')
-rw-r--r--Source/SPCopyTable.m42
1 files changed, 22 insertions, 20 deletions
diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m
index 31b1e6d4..d31ae09d 100644
--- a/Source/SPCopyTable.m
+++ b/Source/SPCopyTable.m
@@ -1238,30 +1238,32 @@ NSInteger kBlobAsImageFile = 4;
if([[self delegate] isKindOfClass:[SPCustomQuery class]]) {
[env setObject:@"query" forKey:SPBundleShellVariableDataTableSource];
NSArray *defs = [[self delegate] dataColumnDefinitions];
- 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"]) ? : @""];
- [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"UNSIGNED_FLAG"]];
- [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"AUTO_INCREMENT_FLAG"]];
- [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"PRI_KEY_FLAG"]];
- [tableMetaData appendString:@"\n"];
- }
+ if(defs && [defs count] == numColumns)
+ 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"]) ? : @""];
+ [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"UNSIGNED_FLAG"]];
+ [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"AUTO_INCREMENT_FLAG"]];
+ [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"PRI_KEY_FLAG"]];
+ [tableMetaData appendString:@"\n"];
+ }
}
else if([[self delegate] isKindOfClass:[SPTableContent class]]) {
[env setObject:@"content" forKey:SPBundleShellVariableDataTableSource];
NSArray *defs = [[self delegate] dataColumnDefinitions];
- 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"]) ? : @""];
- [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"unsigned"]];
- [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"autoincrement"]];
- [tableMetaData appendFormat:@"%@\t", ([col objectForKey:@"isprimarykey"]) ? : @"0"];
- [tableMetaData appendFormat:@"%@\n", [col objectForKey:@"comment"]];
- }
+ if(defs && [defs count] == numColumns)
+ 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"]) ? : @""];
+ [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"unsigned"]];
+ [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"autoincrement"]];
+ [tableMetaData appendFormat:@"%@\t", ([col objectForKey:@"isprimarykey"]) ? : @"0"];
+ [tableMetaData appendFormat:@"%@\n", [col objectForKey:@"comment"]];
+ }
}
free(columnMappings);