[Catalyst] Patch for DBIx::Class::Loader::mysql
Vsevolod (Simon) Ilyushchenko
simonf at cshl.edu
Fri Sep 23 19:44:44 CEST 2005
Sebastian,
Thanks for writing this class - I needed it. I've ran it against my 4.1
mysql database, and here's what I had to change.
Simon
--- /home/files/perl/DBIx-Class-Loader/lib/DBIx/Class/Loader/mysql.pm
2005-09-23 10:10:48.000000000 -0400
+++
/opt/software/perl/lib/perl5/site_perl/5.8.6/DBIx/Class/Loader/mysql.pm
2005-09-23 10:27:11.000000000 -0400
@@ -81,16 +81,16 @@
sub _table_info {
my ( $self, $table ) = @_;
my $dbh = DBI->connect( @{ $self->{_datasource} } ) or
croak($DBI::errstr);
- my $query = "DESCRIBE '$table'";
+ my $query = "DESCRIBE $table";
my $sth = $dbh->prepare($query) or die("Cannot get table status:
$table");
$sth->execute;
my ( @cols, @pri );
- while ( my $hash = $sth->fetch_hash ) {
- my ($col) = $hash->{field} =~ /(\w+)/;
+ while ( my $hash = $sth->fetchrow_hashref ) {
+ my ($col) = $hash->{Field} =~ /(\w+)/;
push @cols, $col;
- push @pri, $col if $hash->{key} eq "PRI";
+ push @pri, $col if $hash->{Key} eq "PRI";
}
- $self->_croak("$table has no primary key") unless @pri;
+ croak("$table has no primary key") unless @pri;
return ( \@cols, \@pri );
}
--
Simon (Vsevolod ILyushchenko) simonf at cshl.edu
http://www.simonf.com
Terrorism is a tactic and so to declare war on terrorism
is equivalent to Roosevelt's declaring war on blitzkrieg.
Zbigniew Brzezinski, U.S. national security advisor, 1977-81
More information about the Catalyst
mailing list