Skip Menu |

This queue is for tickets about the GraphViz-DBI CPAN distribution.

Report information
The Basics
Id: 23192
Status: open
Priority: 0/
Queue: GraphViz-DBI

People
Owner: Nobody in particular
Requestors: dekimsey [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.02
Fixed in: (no value)



Subject: Case Sensitivity discrepancy between is_table() and is_foreign_key()
I was having problems figuring out why GraphViz::DBI wasn't showing the hierarchy in my database when I came across the following two subroutines in GraphViz/DBI.pm The issue came down to the fact that is_foreign_key performs a case insensitive check and is_table's lookup hash (I haven't a clue what line 47 actually does) seems to be case sensitive. As all of the tables in my database are lowercased. Putting in an lc() on line 60 resolved the issue. 45 sub is_table { 46 my ($self, $table) = @_; 47 $self->{is_table} ||= { map { $_ => 1 } $self->get_tables }; 48 return $self->{is_table}{$table}; 49 } 50 51 sub is_foreign_key { 52 # if the field name is of the form "<table>_id" and 53 # "<table>" is an actual table in the database, treat 54 # this as a foreign key. 55 # This is my convention; override it to suit your needs. 56 57 my ($self, $table, $field) = @_; 58 return if $field =~ /$table[_-]id/i; 59 return unless $field =~ /^(.*)[_-]id$/i; 60 my $candidate = $1; 61 return unless $self->is_table($candidate); 62 return $candidate; 63 }