From: Jonathan Yu Date: Sat, 10 Jan 2009 16:56:50 +0000 (+0000) Subject: - Added a show_index_name parameter which determines whether index names should be... X-Git-Tag: v0.11008~259 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d6d6b2055f8cfab6457e42186d805c5663b132a3;p=dbsrgits%2FSQL-Translator.git - Added a show_index_name parameter which determines whether index names should be shown. If false, then the module will just print a list of tuples of indexed fields. - Fixed a bug where unindexed tables would have an extra empty box --- diff --git a/lib/SQL/Translator/Producer/GraphViz.pm b/lib/SQL/Translator/Producer/GraphViz.pm index f72f5e1..125084b 100644 --- a/lib/SQL/Translator/Producer/GraphViz.pm +++ b/lib/SQL/Translator/Producer/GraphViz.pm @@ -178,6 +178,14 @@ set on each table. it describes the index types along with which columns are included in the index. this option requires that show_fields is a true value as well +=item * show_index_name + +if show_indexes is set to a true value, then the value of this +parameter determines whether or not to print names of indexes. +if show_index_name is false, then a list of indexed columns +will appear below the field list. otherwise, it will be a list +prefixed with the name of each index. it defaults to true. + =item * friendly_ints if set to a true value, each integer type field will be displayed @@ -274,6 +282,7 @@ sub produce { my $show_datatypes = $args->{'show_datatypes'}; my $show_sizes = $args->{'show_sizes'}; my $show_indexes = $args->{'show_indexes'}; + my $show_index_name = $args->{'show_index_name'} || 1; my $friendly_ints = $args->{'friendly_ints'}; my $show_constraints = $args->{'show_constraints'}; my $join_pk_only = $args->{'join_pk_only'}; @@ -412,14 +421,20 @@ sub produce { foreach my $index ($table->get_indices) { next unless $index->is_valid; - $index_str .= '*\ ' . $index->name . ': '; + $index_str .= '*\ '; + if ($show_index_name) { + $index_str .= $index->name . ': '; + } $index_str .= join(', ', $index->fields); if ($index->type eq 'UNIQUE') { $index_str .= '\ [U]'; } $index_str .= '\l'; } - $label .= '|' . $index_str; + # Only add the last box if index_str is non-null + if (length $index_str) { + $label .= '|' . $index_str; + } } $label .= '}'; # $gv->add_node( $table_name, label => $label );