Subject: | sqlt-graph: a patch to remove blank skipped table nodes |
Date: | Tue, 4 May 2010 16:44:15 +0800 |
To: | bug-SQL-Translator [...] rt.cpan.org |
From: | Teo Hui Ming <teohuiming [...] gmail.com> |
Hi,
As documented in
http://search.cpan.org/~ribasushi/SQL-Translator/lib/SQL/Translator/Producer/GraphViz.pm
"""
skip_tables
[..] Note that a skipped table node may still appear if another table has
foreign key constraints pointing to the skipped table. If this happens
no table field/index information will be included.
"""
When using --skip-tables (or --skip-tables-like) option in sqlt-graph,
a skipped foreign table will still appear as a blank node in the
diagram . Often we don't want to see these blank nodes in ER diagrams.
In case anyone facing similar issue, here's a quick patch to remove
the blank nodes. :-)
Apply the patch to SQL::Translator::Producer::GraphViz
Index: GraphViz.pm
===================================================================
--- GraphViz.pm (revision 1689)
+++ GraphViz.pm (working copy)
@@ -563,6 +563,15 @@
for my $c ( $table->get_constraints ) {
next unless $c->type eq FOREIGN_KEY;
my $fk_table = $c->reference_table or next;
+
+ # skip the foreign table if exist in
+ # 'skip_tables' or 'skip_tables_like' options.
+ if ( @skip_tables_like or keys %skip_tables ) {
+ next if $skip_tables{ $fk_table };
+ for my $regex ( @skip_tables_like ) {
+ next if $fk_table =~ $regex;
+ }
+ }
for my $field_name ( $c->fields ) {
for my $fk_field ( $c->reference_fields ) {
Cheers,
--
Teo Hui Ming