Subject: | User "0" is false but valide |
I used Ima::DBI in an example talk at the amsterdam.pm.org meeting.
Debugging was needed... :(
H.Merijn Brand <h.m.brand@xs4all.nl> (a well known CPAN author and DBD guru)
pointed me to these lines in Ima::DBI
my $user = shift || "";
my $password = shift || "";
Quote:
"DBI drivers make good use of the difference between undef and false"
Example: $user = '0'; is valide but can't use Ima::DBI
Please remove the ' || "" '
The other change in the attached diff is also harmless
and helped with debugging.
Subject: | DBI.pm.diff |
--- DBI.pm.orig 2007-06-10 22:40:22.000000000 +0200
+++ DBI.pm 2011-07-06 03:26:23.000000000 +0200
@@ -263,14 +263,14 @@
sub set_db {
my $class = shift;
- my $db_name = shift or $class->_croak("Need a db name");
+ my $db_name = shift or $class->_croak("$class Need a db name");
$db_name =~ s/\s/_/g;
- my $data_source = shift or $class->_croak("Need a data source");
- my $user = shift || "";
- my $password = shift || "";
+ my $data_source = shift or $class->_croak("$class Need a data source");
+ my $user = shift;
+ my $password = shift;
my $attr = shift || {};
- ref $attr eq 'HASH' or $class->_croak("$attr must be a hash reference");
+ ref $attr eq 'HASH' or $class->_croak("$class $attr must be a hash reference");
$attr = $class->_add_default_attributes($attr);
$class->_remember_handle($db_name);