Subject: | identifier quote wrong |
Date: | Wed, 30 Sep 2009 15:15:18 -0700 |
To: | "bug-DBIx-Log4perl [...] rt.cpan.org" <bug-DBIx-Log4perl [...] rt.cpan.org> |
From: | David Gasson <DavidG [...] airg.com> |
Hi folks,
I'm keen to use DBIx::Log4perl--it's exactly what I'm looking for. But I noticed a problem. Below is a script that demonstrates it:
use strict;
use warnings;
my $dsn = 'DBI:mysql:database=mydb;host=localhost';
my $user = 'myuser';
my $pass = 'mypass';
sub show_quotes {
my ($dbh, $type) = @_;
print "Table name w/ quotes ($type): ", $dbh->quote_identifier('Account'), "\n";
}
{
use DBI;
my $dbh = DBI->connect($dsn, $user, $pass) or die DBI->errstr;
show_quotes($dbh, 'DBI');
$dbh->disconnect;
}
{
use Log::Log4perl qw/:easy/;
Log::Log4perl->easy_init($DEBUG);
use DBIx::Log4perl;
my $dbh = DBIx::Log4perl->connect($dsn, $user, $pass) or die DBI->errstr;
show_quotes($dbh, 'DBIx::Log4perl');
$dbh->disconnect;
}
In the first case, all is well and the following is outputted:
Table name w/ quotes (DBI): `Account`
But in the second case (with DBIx::Log4perl):
Table name w/quotes (DBIx::Log4perl): "Account"
Which is wrong in MySQL. The fix seems really straightforward, though. In DBIx/Log4perl/db.pm simply change:
sub get_info
{
my ($dbh, @args) = @_;
my $h = $dbh->{private_DBIx_Log4perl};
my $value = $dbh->SUPER::get_info(@args);
$dbh->_dbix_l4p_debug($h, 2, "get_info($h->{dbh_no})", @args, $value)
if ($h->{logmask} & DBIX_L4P_LOG_INPUT);
}
To:
sub get_info
{
my ($dbh, @args) = @_;
my $h = $dbh->{private_DBIx_Log4perl};
my $value = $dbh->SUPER::get_info(@args);
$dbh->_dbix_l4p_debug($h, 2, "get_info($h->{dbh_no})", @args, $value)
if ($h->{logmask} & DBIX_L4P_LOG_INPUT);
return $value;
}
The only difference between the two is the addition of the "return $value" line. Is that the right solution? Things seem to work flawlessly after that change is made. FYI, here are the various versions of things I'm using in case it's relevant:
MySQL: 5.0.22
DBI: 1.609
DBD::mysql: 4.013
Log::Log4perl: 1.25
DBIx::Log4perl: 0.15
perl: 5.8.8
Oh, and this is on Linux. If you need any more information, please don't hesitate to ask! Totally digging DBIx::Log4perl otherwise...
Cheers,
David
David Gasson
Programmer
airG
Suite 706, 1155 Robson Street
Vancouver, B.C.
Canada V6E 1B5
T: +1.604.408.2228
F: +1.866.874.8136
E: davidg@airg.com
W: www.airg.com