DBSchema::DBD::mysql NAME vs NAME_lc patch from Ralf Hack, closes: CPAN#16715.
authorivan <ivan>
Thu, 28 Jun 2007 03:17:33 +0000 (03:17 +0000)
committerivan <ivan>
Thu, 28 Jun 2007 03:17:33 +0000 (03:17 +0000)
DBSchema::DBD::Mysql fix for additional column data from Chris Mungall, closes: CPAN#20859, thanks!

DBSchema/DBD/mysql.pm

index ef7bb59..924c309 100644 (file)
@@ -34,10 +34,12 @@ This module implements a MySQL-native driver for DBIx::DBSchema.
 
 sub columns {
   my($proto, $dbh, $table ) = @_;
+  my $oldkhv=$dbh->{FetchHashKeyName};
+  $dbh->{FetchHashKeyName}="NAME";
   my $sth = $dbh->prepare("SHOW COLUMNS FROM $table") or die $dbh->errstr;
   $sth->execute or die $sth->errstr;
-  map {
-    $_->{'Type'} =~ /^(\w+)\(?([^)]+)?\)?( unsigned)?$/
+  my @r = map {
+    $_->{'Type'} =~ /^(\w+)\(?([^)]+)?\)?( \d+)?$/
       or die "Illegal type: ". $_->{'Type'}. "\n";
     my($type, $length) = ($1, $2);
     [
@@ -49,6 +51,8 @@ sub columns {
       $_->{'Extra'}
     ]
   } @{ $sth->fetchall_arrayref( {} ) };
+  $dbh->{FetchHashKeyName}=$oldkhv;
+  @r;
 }
 
 #sub primary_key {
@@ -83,6 +87,8 @@ sub index {
 
 sub _show_index {
   my($proto, $dbh, $table ) = @_;
+  my $oldkhv=$dbh->{FetchHashKeyName};
+  $dbh->{FetchHashKeyName}="NAME";
   my $sth = $dbh->prepare("SHOW INDEX FROM $table")
     or die $dbh->errstr;
   $sth->execute or die $sth->errstr;
@@ -98,6 +104,7 @@ sub _show_index {
       push @{ $unique{ $row->{'Key_name'} } }, $row->{'Column_name'};
     }
   }
+  $dbh->{FetchHashKeyName}=$oldkhv;
 
   ( $pkey, \%unique, \%index );
 }