Subject: | Detecting foreign keys in MySQL fails |
Version: 0.12
File: lib/Class/DBI/Loader/mysql.pm
MySQL-Version: 4.1.8a-Debian_1-log
The query SHOW TABLE STATUS FROM dbname LIKE 'table' produces for the comment column something like
InnoDB free: 11264 kB; (`column`) REFER `dbname/table`(`id`)
Note the backticks.
The patch tries to match those backticks.
--- /usr/local/lib/perl5/site_perl/5.8.4/Class/DBI/Loader/mysql.pm 2005-02-01 15:13:52.000000000 +0100
+++ mysql.pm 2005-01-27 07:45:49.000000000 +0100
@@ -55,9 +55,9 @@
foreach ( split( /\;/, $comment ) ) {
next unless $_ =~ m/REFER/i;
my ( $local_key, $foreign_key ) = split( /\sREFER\s/, $_ );
- $local_key =~ m/\(`?(\w*)`?\)/;
+ $local_key =~ m/\((\w*)\)/;
my $column = $1;
- $foreign_key =~ m/`?(\w*)\/+(\w*)`?\(`?(\w*)`?\)/;
+ $foreign_key =~ m/(\w*)\/+(\w*)\((\w*)\)/;
my $other = $2;
$self->_has_a_many( $table, $column, $other );
}