Subject: | SQL::Translator::Producer::Diagram has empty |
Date: | Fri, 26 Aug 2011 15:02:13 +1200 |
To: | bug-SQL-Translator [...] rt.cpan.org |
From: | banjo <banjo [...] scoop.co.nz> |
hi
i got an error using sqlfairy to parse a Postgresql schema...
bash$ sqlt-diagram --db=PostgreSQL -o schema.png -i png schema.sql
Error: translate: Error with producer 'SQL::Translator::Producer::Diagram': Can't call method "get_fields" on an undefined value at
/usr/share/perl5/SQL/Translator/Producer/Diagram.pm line 197.
adding some diagnostic code i found that (for some reason)
the *first* entry from @table_names (see below) was an empty...
## SQL::Translator::Producer::Diagram - Line 175
TABLE:
for my $table_name ( @table_names ) {
warn "Got $table_name\n"; ##### <------ my debug
my $table = $schema->get_table( $table_name );
if ( @skip_tables_like or keys %skip_table ) {
next TABLE if $skip_table{ $table_name };
for my $regex ( @skip_tables_like ) {
next TABLE if $table_name =~ $regex;
}
}
i did a quick hack/patch that solved this...
TABLE:
for my $table_name ( @table_names ) {
next unless $table_name; #### <---------- my fix
my $table = $schema->get_table( $table_name );
if ( @skip_tables_like or keys %skip_table ) {
next TABLE if $skip_table{ $table_name };
for my $regex ( @skip_tables_like ) {
next TABLE if $table_name =~ $regex;
}
}
there's prolly issues with my schema,
and certainly issues with your code.
sorry, i can't give you the schema
but it was produced by running pg_dump on a production db.
cheers
-billy