aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPExtendedTableInfo.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-07-07 11:14:04 +0000
committerBibiko <bibiko@eva.mpg.de>2010-07-07 11:14:04 +0000
commit367bacf28308da7744870c97f2317c8936e8c507 (patch)
tree72767d01959a1198ee08b336815f6ca2b2c5d294 /Source/SPExtendedTableInfo.m
parenta80974fc632de621fbd7a917bfbf52259650d80a (diff)
downloadsequelpro-367bacf28308da7744870c97f2317c8936e8c507.tar.gz
sequelpro-367bacf28308da7744870c97f2317c8936e8c507.tar.bz2
sequelpro-367bacf28308da7744870c97f2317c8936e8c507.zip
• avoid exceptions if user tries to print the Table Status data of Views, Procs, or Funcs (maybe it's needed to improve the display or to skip it)
Diffstat (limited to 'Source/SPExtendedTableInfo.m')
-rw-r--r--Source/SPExtendedTableInfo.m59
1 files changed, 37 insertions, 22 deletions
diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m
index 0bd95fa4..aac89bb9 100644
--- a/Source/SPExtendedTableInfo.m
+++ b/Source/SPExtendedTableInfo.m
@@ -383,28 +383,42 @@
NSMutableDictionary *tableInfo = [NSMutableDictionary dictionary];
NSDictionary *statusFields = [tableDataInstance statusValues];
-
- [tableInfo setObject:[tableTypePopUpButton titleOfSelectedItem] forKey:@"type"];
- [tableInfo setObject:[tableEncodingPopUpButton titleOfSelectedItem] forKey:@"encoding"];
- [tableInfo setObject:[tableCollationPopUpButton titleOfSelectedItem] forKey:@"collation"];
-
- [tableInfo setObject:[self _formatValueWithKey:@"Create_time" inDictionary:statusFields] forKey:@"createdAt"];
- [tableInfo setObject:[self _formatValueWithKey:@"Update_time" inDictionary:statusFields] forKey:@"updatedAt"];
- [tableInfo setObject:[self _formatValueWithKey:@"Rows" inDictionary:statusFields] forKey:@"rowNumber"];
- [tableInfo setObject:[self _formatValueWithKey:@"Row_format" inDictionary:statusFields] forKey:@"rowFormat"];
- [tableInfo setObject:[self _formatValueWithKey:@"Avg_row_length" inDictionary:statusFields] forKey:@"rowAvgLength"];
- [tableInfo setObject:[self _formatValueWithKey:@"Auto_increment" inDictionary:statusFields] forKey:@"rowAutoIncrement"];
- [tableInfo setObject:[self _formatValueWithKey:@"Data_length" inDictionary:statusFields] forKey:@"dataSize"];
- [tableInfo setObject:[self _formatValueWithKey:@"Max_data_length" inDictionary:statusFields] forKey:@"maxDataSize"];
- [tableInfo setObject:[self _formatValueWithKey:@"Index_length" inDictionary:statusFields] forKey:@"indexSize"];
+
+ if([tableTypePopUpButton titleOfSelectedItem])
+ [tableInfo setObject:[tableTypePopUpButton titleOfSelectedItem] forKey:@"type"];
+ if([tableEncodingPopUpButton titleOfSelectedItem])
+ [tableInfo setObject:[tableEncodingPopUpButton titleOfSelectedItem] forKey:@"encoding"];
+ if([tableCollationPopUpButton titleOfSelectedItem])
+ [tableInfo setObject:[tableCollationPopUpButton titleOfSelectedItem] forKey:@"collation"];
+
+ if([self _formatValueWithKey:@"Create_time" inDictionary:statusFields])
+ [tableInfo setObject:[self _formatValueWithKey:@"Create_time" inDictionary:statusFields] forKey:@"createdAt"];
+ if([self _formatValueWithKey:@"Update_time" inDictionary:statusFields])
+ [tableInfo setObject:[self _formatValueWithKey:@"Update_time" inDictionary:statusFields] forKey:@"updatedAt"];
+ if([self _formatValueWithKey:@"Rows" inDictionary:statusFields])
+ [tableInfo setObject:[self _formatValueWithKey:@"Rows" inDictionary:statusFields] forKey:@"rowNumber"];
+ if([self _formatValueWithKey:@"Row_format" inDictionary:statusFields])
+ [tableInfo setObject:[self _formatValueWithKey:@"Row_format" inDictionary:statusFields] forKey:@"rowFormat"];
+ if([self _formatValueWithKey:@"Avg_row_length" inDictionary:statusFields])
+ [tableInfo setObject:[self _formatValueWithKey:@"Avg_row_length" inDictionary:statusFields] forKey:@"rowAvgLength"];
+ if([self _formatValueWithKey:@"Auto_increment" inDictionary:statusFields])
+ [tableInfo setObject:[self _formatValueWithKey:@"Auto_increment" inDictionary:statusFields] forKey:@"rowAutoIncrement"];
+ if([self _formatValueWithKey:@"Data_length" inDictionary:statusFields])
+ [tableInfo setObject:[self _formatValueWithKey:@"Data_length" inDictionary:statusFields] forKey:@"dataSize"];
+ if([self _formatValueWithKey:@"Max_data_length" inDictionary:statusFields])
+ [tableInfo setObject:[self _formatValueWithKey:@"Max_data_length" inDictionary:statusFields] forKey:@"maxDataSize"];
+ if([self _formatValueWithKey:@"Index_length" inDictionary:statusFields])
+ [tableInfo setObject:[self _formatValueWithKey:@"Index_length" inDictionary:statusFields] forKey:@"indexSize"];
[tableInfo setObject:[self _formatValueWithKey:@"Data_free" inDictionary:statusFields] forKey:@"sizeFree"];
-
- [tableInfo setObject:[tableCommentsTextView string] forKey:@"comments"];
-
+
+ if([tableCommentsTextView string])
+ [tableInfo setObject:[tableCommentsTextView string] forKey:@"comments"];
+
NSError *error = nil;
NSArray *HTMLExcludes = [NSArray arrayWithObjects:@"doctype", @"html", @"head", @"body", @"xml", nil];
- NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:NSHTMLTextDocumentType, NSDocumentTypeDocumentAttribute, HTMLExcludes, NSExcludedElementsDocumentAttribute, nil];
+ NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:NSHTMLTextDocumentType,
+ NSDocumentTypeDocumentAttribute, HTMLExcludes, NSExcludedElementsDocumentAttribute, nil];
// Set tableCreateSyntaxTextView's font size temporarily to 10pt for printing
NSFont *oldFont = [tableCreateSyntaxTextView font];
@@ -413,7 +427,8 @@
[tableCreateSyntaxTextView setFont:[NSFont fontWithName:[oldFont fontName] size:10.0]];
// Convert tableCreateSyntaxTextView to HTML
- NSData *HTMLData = [[tableCreateSyntaxTextView textStorage] dataFromRange:NSMakeRange(0, [[tableCreateSyntaxTextView string] length]) documentAttributes:attributes error:&error];
+ NSData *HTMLData = [[tableCreateSyntaxTextView textStorage] dataFromRange:NSMakeRange(0, [[tableCreateSyntaxTextView string] length])
+ documentAttributes:attributes error:&error];
// Restore original font settings
[tableCreateSyntaxTextView setFont:oldFont];
@@ -421,12 +436,12 @@
if (error != nil) {
NSLog(@"Error generating table's create syntax HTML for printing. Excluding from print out. Error was: %@", [error localizedDescription]);
-
+
return tableInfo;
}
-
+
NSString *HTMLString = [[[NSString alloc] initWithData:HTMLData encoding:NSUTF8StringEncoding] autorelease];
-
+
[tableInfo setObject:HTMLString forKey:@"createSyntax"];
return tableInfo;