aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormtvee <emptyvee@gmail.com>2009-06-11 00:20:00 +0000
committermtvee <emptyvee@gmail.com>2009-06-11 00:20:00 +0000
commitf54791648b44925321f2d9c631d9782574fecf51 (patch)
treef89d65463cdd9e651206dd2ade9d97d236c9206f
parent910d3dcf2fcea97d445b94ba902f8a0b8279916e (diff)
downloadsequelpro-f54791648b44925321f2d9c631d9782574fecf51.tar.gz
sequelpro-f54791648b44925321f2d9c631d9782574fecf51.tar.bz2
sequelpro-f54791648b44925321f2d9c631d9782574fecf51.zip
updated dot generator to handle multi-col fk's with a different arrow type and views as a different header color
-rw-r--r--Source/SPTableData.m3
-rw-r--r--Source/TableDump.m23
2 files changed, 22 insertions, 4 deletions
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index a5e29a9d..f2e0c77e 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -317,6 +317,7 @@
// Retrieve the table syntax string
NSArray *syntaxResult = [theResult fetchRowAsArray];
+ NSArray *resultFieldNames = [theResult fetchFieldNames];
if ([[syntaxResult objectAtIndex:1] isKindOfClass:[NSData class]]) {
tableCreateSyntax = [[NSString alloc] initWithData:[syntaxResult objectAtIndex:1] encoding:[mySQLConnection encoding]];
@@ -520,6 +521,8 @@
[fieldParser release];
tableData = [NSMutableDictionary dictionary];
+ // this will be 'Table' or 'View'
+ [tableData setObject:[resultFieldNames objectAtIndex:0] forKey:@"type"];
[tableData setObject:[NSString stringWithString:encodingString] forKey:@"encoding"];
[tableData setObject:[NSArray arrayWithArray:tableColumns] forKey:@"columns"];
[tableData setObject:[NSArray arrayWithArray:constraints] forKey:@"constraints"];
diff --git a/Source/TableDump.m b/Source/TableDump.m
index 985564fd..a309c22a 100644
--- a/Source/TableDump.m
+++ b/Source/TableDump.m
@@ -1186,12 +1186,16 @@
[singleProgressBar setUsesThreadedAnimation:YES];
[singleProgressBar startAnimation:self];
+ NSString *hdrColor = @"#DDDDDD";
+ if( [[tinfo objectForKey:@"type"] isEqualToString:@"View"] ) {
+ hdrColor = @"#DDDDFF";
+ }
[metaString setString:[NSString stringWithFormat:@"\tsubgraph \"table_%@\" {\n", tableName]];
[metaString appendString:@"\t\tnode = [ shape = \"plaintext\" ];\n"];
[metaString appendString:[NSString stringWithFormat:@"\t\t\"%@\" [ label=<\n", tableName]];
[metaString appendString:@"\t\t\t<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLBORDER=\"1\">\n"];
- [metaString appendString:[NSString stringWithFormat:@"\t\t\t<TR><TD COLSPAN=\"3\" BGCOLOR=\"#DDDDDD\">%@</TD></TR>\n", tableName]];
+ [metaString appendString:[NSString stringWithFormat:@"\t\t\t<TR><TD COLSPAN=\"3\" BGCOLOR=\"%@\">%@</TD></TR>\n", hdrColor, tableName]];
// grab column info
NSArray *cinfo = [tinfo objectForKey:@"columns"];
@@ -1207,11 +1211,22 @@
// see about relations
cinfo = [tinfo objectForKey:@"constraints"];
for( int j = 0; j < [cinfo count]; j++ ) {
- [fkInfo addObject:[NSString stringWithFormat:@"%@:%@ -> %@:%@",
+ // get the column refs. these can be comma separated.
+ NSString *ccol = [[cinfo objectAtIndex:j] objectForKey:@"columns"];
+ NSString *rcol = [[cinfo objectAtIndex:j] objectForKey:@"ref_columns"];
+ NSString *extra = @"";
+ NSArray *tc = [ccol componentsSeparatedByString:@","];
+ if( [tc count] > 1 ) {
+ extra = @" [ arrowhead=crow, arrowtail=odiamond ]";
+ ccol = [tc objectAtIndex:0];
+ rcol = [[ccol componentsSeparatedByString:@","] objectAtIndex:0];
+ }
+ [fkInfo addObject:[NSString stringWithFormat:@"%@:%@ -> %@:%@ %@",
tableName,
- [[cinfo objectAtIndex:j] objectForKey:@"columns"],
+ ccol,
[[cinfo objectAtIndex:j] objectForKey:@"ref_table"],
- [[cinfo objectAtIndex:j] objectForKey:@"ref_columns"]
+ rcol,
+ extra
]];
}