Subject: | Mysql loader broken by mysql 4.0.17 / DBD 2.9003 |
The mysql DBD now returns the tables in ->tables quoted by a backtick:
If "$dbh->get_info(29)" returns true (29 is SQL_IDENTI-
FIER_QUOTE_CHAR) then the table names are constructed and quoted by
"quote_identifier" to ensure they are usable even if they contain
whitespace or reserved words etc. This means that the table names
returned will include quote characters.
This means the class names end up being "MyApp::`foo`".
--- Class/DBI/Loader/mysql.pm~ 2004-01-24 11:47:59.000000000 +0000
+++ Class/DBI/Loader/mysql.pm 2004-01-24 11:50:05.000000000 +0000
@@ -15,7 +15,7 @@
my $self = shift;
my $dbh = DBI->connect(@{$self->_datasource}) or _croak($DBI::errstr);
foreach my $table($dbh->tables) {
- my $class = $self->_table2class($table);
+ my $class = $self->_table2class($table, $dbh);
no strict 'refs';
@{"$class\::ISA"} = qw(Class::DBI::mysql);
$class->set_db(Main => @{$self->_datasource});
--- Class/DBI/Loader/Generic.pm~ 2004-01-24 11:48:23.000000000 +0000
+++ Class/DBI/Loader/Generic.pm 2004-01-24 11:54:19.000000000 +0000
@@ -41,10 +41,13 @@
}
sub _table2class {
- my($self, $table) = @_;
+ my($self, $table, $dbh) = @_;
my $namespace = $self->{_namespace} || "";
$namespace =~ s/(.*)::$/$1/;
my $subclass = $table;
+ if ($dbh and my $quoter = $dbh->get_info(29)) {
+ $subclass =~ s/$quoter//g;
+ }
$subclass =~ s/_(\w)/ucfirst($1)/eg;
my $class = $namespace ? "$namespace\::". ucfirst($subclass) : ucfirst($subclass);
}