Skip Menu |
 

This queue is for tickets about the DBIx-DBH CPAN distribution.

Report information
The Basics
Id: 18026
Status: resolved
Worked: 45 min
Priority: 0/
Queue: DBIx-DBH

People
Owner: metaperl [...] gmail.com
Requestors: mark [...] summersault.com
Cc:
AdminCc:

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



Subject: PATCH: add a new driver without modifying DBIx::DBH
Download (untitled) / with headers
text/plain 446b
Just as DBI needs no modifications for a new driver to work, neither should this module. I've attached a patch which refactors the code to address this. Rather than relying on a hardcoded list, it tries to 'require' the driver, or dies with a related error message. This could lower your own maintenance effort, as others can publish additional drivers directly without requiring a new release of DBIx::DBH for it to work.
Subject: nomod.patch
Download nomod.patch
text/x-diff 2.4k
Mon Mar 6 21:12:44 EST 2006 Mark Stosberg <mark@summersault.com> * Allow new drivers without needing modification to DBIx::DBH diff -rN -u old-DBIx-DBH-0.09/ChangeLog new-DBIx-DBH-0.09/ChangeLog --- old-DBIx-DBH-0.09/ChangeLog 2006-03-06 21:14:34.000000000 -0500 +++ new-DBIx-DBH-0.09/ChangeLog 2006-03-06 21:14:34.000000000 -0500 @@ -1,3 +1,6 @@ + + * Allow new drivers to published and used without modifying DBIx::DBH (Mark Stosberg) + 2004-12-01 Terrence Brannon <terry@hcoop.net> * changed "vendor" key to driver per Cavaletto diff -rN -u old-DBIx-DBH-0.09/lib/DBIx/DBH.pm new-DBIx-DBH-0.09/lib/DBIx/DBH.pm --- old-DBIx-DBH-0.09/lib/DBIx/DBH.pm 2006-03-06 21:14:34.000000000 -0500 +++ new-DBIx-DBH-0.09/lib/DBIx/DBH.pm 2006-03-06 21:14:34.000000000 -0500 @@ -9,37 +9,7 @@ use DBI; use Params::Validate qw( :all ); -#use DBIx::DBH::mysql; -#use DBIx::DBH::Pg; - - -require Exporter; - -my @driver = qw(mysql Pg Sybase); -my $driver = join '|', @driver; -my $driver_re = qr/($driver)/ ; - -our @ISA = qw(Exporter); - -# Items to export into callers namespace by default. Note: do not export -# names by default without a very good reason. Use EXPORT_OK instead. -# Do not simply export all your public functions/methods/constants. - -# This allows declaration use DBIx::DBH ':all'; -# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK -# will save memory. -our %EXPORT_TAGS = ( 'all' => [ qw( - -) ] ); - -our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); - -our @EXPORT = qw( - -); - -our $VERSION = '0.09'; - +our $VERSION = '0.10'; our @attr = qw ( @@ -127,15 +97,9 @@ my $class = shift; my %p = @_; - %p = validate( @_, { driver => { callbacks => - { "only valid drivers are @driver" => - sub { $_[0] =~ $driver_re } }}} ) ; - my $subclass = "DBIx::DBH::$p{driver}"; - - my $eval_string = "require $subclass"; - - eval $eval_string; + eval "require $subclass"; + die "unable to require $subclass to support the $p{driver} driver.\n" if $@; my ($dsn, $user, $pass, $attr) = $subclass->connect_data(@_); $attr = dbi_attr($attr, %p); @@ -254,16 +218,8 @@ =head1 ADDING A DRIVER -Consists of these steps: - -=over - -=item * adding a word to the C<@driver> array in DBH.pm - -this array consists of whitespace-separated driver names and is used to -validate drivers in C<connect_data> - -=item * adding a module to the C<DBIx::DBH> hiearchy +Simply add a new driver with a name of C<DBIx::DBH::$Driver>, where +C<$Driver> is a valid DBI driver name. =back
Download (untitled) / with headers
text/plain 677b
On Mon Mar 06 21:19:13 2006, guest wrote: Show quoted text
> Just as DBI needs no modifications for a new driver to work, neither > should this module.
great insight. I never thought of that design objective. Show quoted text
> > I've attached a patch which refactors the code to address this.
sweet. thanks. applied. Show quoted text
> > Rather than relying on a hardcoded list, it tries to 'require' the > driver, or dies with a related error message. > > This could lower your own maintenance effort, as others can publish > additional drivers directly without requiring a new release of > DBIx::DBH for it to work.
yes I've credited you in the AUTHORS section of the 0.10 release to CPAN. Show quoted text
> >


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.