Subject: | connect() not accepting dbname in attrs hash |
Date: | Wed, 14 Oct 2015 00:13:19 -0500 |
To: | bug-DBD-Pg [...] rt.cpan.org |
From: | Felipe Gasper <felipe [...] felipegasper.com> |
Observe that the attrs hashref in the first example doesn’t affect the
actual database logged into.
Show quoted text
> perl -MData::Dumper -MDBI -e'my $dbh = DBI->connect("dbi:Pg:",
"postgres", undef, { dbname => "mortal_nouveau" } ); print Dumper(
$dbh->selectall_arrayref("select current_database()") )'
$VAR1 = [
[
'postgres'
]
];
Only when $ENV{PGDATABASE} is set does the expected behavior happen:
Show quoted text > perl -MData::Dumper -MDBI -e'$ENV{PGDATABASE} = "mortal_nouveau"; my
$dbh = DBI->connect("dbi:Pg:", "postgres", undef, { dbnam =>
"mortal_nouveau" } ); print Dumper( $dbh->selectall_arrayref("select
current_database()") )'
$VAR1 = [
[
'mortal_nouveau'
]
];
This is DBD::Pg version 3.5.3.