How strict should handler attributes be checked?
Isn't barfing on fetchrow_hashref () not a tad bit too late in below
described situation?
/tmp > cat test.pl
#!/pro/bin/perl
use strict;
use warnings;
use DBI;
use Data::Peek;
my ($dsn, $fhkn) = @ARGV;
my $dbh = DBI->connect ($dsn, $ENV{DBI_USER}, $ENV{DBI_PASS}, {
FetchHashKeyName => $fhkn,
PrintError => 1,
RaiseError => 1,
}) or die $DBI::errstr;
my $sth = $dbh->prepare ("select * from test");
$sth->execute;
DDumper $sth->fetchrow_hashref;
/tmp >
/tmp > perl test.pl dbi:Pg: NAME_lc
$VAR1 = {
c_test => '1',
test => 'test'
};
/tmp > perl test.pl dbi:Pg: NAME_uc
$VAR1 = {
C_TEST => '1',
TEST => 'test'
};
/tmp > perl test.pl dbi:Pg: NAME
$VAR1 = {
c_test => '1',
test => 'test'
};
/tmp > perl test.pl dbi:Pg: 1
DBD::Pg::st fetchrow_hashref failed: Can't use attribute '1' because it doesn't
contain a reference to an array (undef) at test.pl line 19.
DBD::Pg::st fetchrow_hashref failed: Can't use attribute '1' because it doesn't
contain a reference to an array (undef) at test.pl line 19.
Exit 255
/tmp >
/tmp > perl test.pl dbi:CSV: NAME_lc
$VAR1 = {
c_test => '1',
test => 'test'
};
/tmp > perl test.pl dbi:CSV: NAME_uc
$VAR1 = {
C_TEST => '1',
TEST => 'test'
};
/tmp > perl test.pl dbi:CSV: NAME
$VAR1 = {
c_test => '1',
test => 'test'
};
/tmp > perl test.pl dbi:CSV: 1
DBD::CSV::st fetchrow_hashref failed: Can't use attribute '1' because it
doesn't contain a reference to an array (undef) [for Statement "select * from
test"] at test.pl line 19.
DBD::CSV::st fetchrow_hashref failed: Can't use attribute '1' because it
doesn't contain a reference to an array (undef) [for Statement "select * from
test"] at test.pl line 19.
Exit 255
/tmp >
--
H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/
using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/