Subject: | set_db should not set username, password to "" |
Date: | Wed, 20 Mar 2013 15:08:27 -0400 |
To: | Bug-Ima-DBI [...] rt.cpan.org |
From: | Brian Zappia <brian.zappia [...] online-rewards.com> |
The code for set_db in 0.35 contains the following lines:
my $user = shift || "";
my $password = shift || "";
my $attr = shift || {};
No! Bad Programmer! undef means undef, not "". If the username and password passed to set_db were undefined, they were intended to be undefined. If the username and password are undef, DBI:mysql will look for the user name and password in config file which can be passed as part of the datasource string. If, however, you pass the empty string, DBI::mysql will attempt to login with a user who's name is the empty string and with a password that is an empty string. Two very different behaviors. The correct code is:
my $user = shift;
my $password = shift;
my $attr = shift;
Brian