Subject: | DBI:quote returns NULL for tied hash variables. |
perl: v5.8.0
DBI.pm: v 11.42
Problem:
dbi->quote(%hash->{'value'}) returns NULL if "%hash" is tied but valid.
Example:
use strict;
use DBI;
use Apache::Session::MySQL;
use Data::Dumper;
my $dbh = DBI->connect( "dbi:mysql:database=$db", $user, $pass);
my $sessionId = '0167d73142462923e29ef694839a26c2';
my %session;
tie %session, 'Apache::Session::MySQL', $sessionId,
{
'Handle' => $dbh,
'LockHandle' => $dbh,
};
my $session = \%session;
my $username = $session->{'username'};
$Data::Dumper::Indent= 1;
print Dumper($session) . "\n";
print $username . "\n";
print $session->{'username'} . "\n";
print $$session{'username'} . "\n\n";
print $dbh->quote( $session->{'username'} ) . "\n";
print $dbh->quote( ${ \$session->{'username'} } ) . "\n";
print $dbh->quote( $session{username} ) . "\n\n";
print $dbh->quote( $$session{username} ) . "\n";
print $dbh->quote($username) . "\n";
print $dbh->quote( "$session->{'username'}");
Produces:
$VAR1 = {
'name' => undef,
'logged in' => 'y',
'cookie' => '0167d73142462923e29ef694839a26c2',
'username' => 'tESTING',
'_session_id' => '0167d73142462923e29ef694839a26c2',
'last used' => 1075436736
};
tESTING
tESTING
tESTING
NULL
NULL
NULL
NULL
'tESTING'
'tESTING'
As you can see, anything that forces the tied value into a scalar context works, anything that does not results in a NULL.