Skip Menu |
 

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

Report information
The Basics
Id: 17546
Status: new
Priority: 0/
Queue: Class-DBI-Loader

People
Owner: Nobody in particular
Requestors: frank [...] planet-interview.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.30
Fixed in: (no value)



Subject: Foreign keys and MySQL 5
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1139435211-32126-1"
Content-Length: 0
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 299
Download (untitled) / with headers
text/plain 299b
CDBI::Loader::mysql's _relationships uses the 'Comment' column to determine foreign keys. In MySQL 5 this column is trimmed (to 100 chars at my installation), so sometimes information gets lost. But you can use the new information_schema database to get foreign key information. Patch is attached.
Subject: mysql.pm.patch
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_1139435210-32126-0"
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Length: 0
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Type: application/octet-stream; name="mysql.pm.patch"
Content-Disposition: inline; filename="mysql.pm.patch"
Content-Transfer-Encoding: base64
Content-Length: 1420
Download mysql.pm.patch
text/x-diff 1.3k
--- /usr/local/share/perl/5.8.7/Class/DBI/Loader/mysql.pm 2006-02-04 15:07:30.000000000 +0100 +++ mysql.pm 2006-02-08 22:37:42.000000000 +0100 @@ -50,8 +50,28 @@ my $dbname = $conn{database} || $conn{dbname} || $conn{db}; die("Can't figure out the table name automatically.") if !$dbname; my $quoter = $dbh->get_info(29); + my $is_mysql5 = $dbh->get_info(18) =~ /^5./; foreach my $table (@tables) { + if ( $is_mysql5 ) { + my $query = qq( + SELECT column_name, + referenced_table_name + FROM information_schema.key_column_usage + WHERE referenced_table_name IS NOT NULL + AND table_schema = ? + AND table_name = ? + ); + my $sth = $dbh->prepare($query) + or die("Cannot get table information: $table"); + $sth->execute($dbname, $table); + while ( my $data = $sth->fetchrow_hashref ) { + eval { $self->_has_a_many( $table, $data->{column_name}, $data->{referenced_table_name} ) }; + warn qq/\# has_a_many failed "$@"\n\n/ if $@ && $self->debug; + } + $sth->finish; + next; + } my $query = "SHOW TABLE STATUS FROM $dbname LIKE '$table'"; my $sth = $dbh->prepare($query) or die("Cannot get table status: $table");


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.