Skip Menu |
 

This queue is for tickets about the DBI CPAN distribution.

Report information
The Basics
Id: 96763
Status: open
Priority: 0/
Queue: DBI

People
Owner: Nobody in particular
Requestors: zaucker [...] oetiker.ch
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Suggestion: allow Object with stringify overloading as passwd in connect()
Date: Fri, 27 Jun 2014 13:25:25 +0200 (CEST)
To: bug-DBI [...] rt.cpan.org
From: Fritz Zaucker <zaucker [...] oetiker.ch>
Download (untitled) / with headers
text/plain 1.6k
Dear DBI-maintainers, first of all, many thanks for your great work on this module. I recently used Damian Conway's IO::Prompter module to ask the user for a DB-password to be used later in a call to DBI->connect(). As it turns out, DBI->connect() tests the parameter passed as password (for being a string, I guess): Carp::croak('Usage: $class->connect([$dsn [,$user [,$passwd [,\%attr]]]])') if (ref $old_driver or ($attr and not ref $attr) or ref $pass); # ^^^^^^^^^ IO::Prompter->prompt() returns an object with lazy evaluation of the user's input (unless called with the -verbatim option). Therefore my $dsn = 'whatever'; my $user = 'fritz'; my $passwd = IO::Prompter->prompt(); DBI->connect($dsn, $user, $passwd); will croak(). This would solve the problem: use overload; Carp::croak('Usage: $class->connect([$dsn [,$user [,$passwd [,\%attr]]]])') if (ref $old_driver or ($attr and not ref $attr) or (ref $pass and not overload::Method($pass,q{""})); (as suggested by Damian). Now, this is not really a very pressing issue, as I can always use the -verbatim option for IO::Prompter (or force the lazy evaluation before calling DBI->connect(). But perhaps you might want to use the above patch (overload being a core module should make this painless for users of DBI). Cheers, Fritz -- Oetiker+Partner AG tel: +41 62 775 9903 (direct) Fritz Zaucker +41 62 775 9900 (switch board) Aarweg 15 +41 79 675 0630 (mobile) CH-4600 Olten fax: +41 62 775 9905 Schweiz web: www.oetiker.ch
Download (untitled) / with headers
text/plain 194b
Thanks for the suggestion Fritz. As you say, it's not a high priority. However, if you want to contribute, I'd consider a patch that only loads the overload module if needed and includes tests.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.