On Thu, Mar 04, 2004 at 01:23:32AM -1000, Beau E. Cox wrote:
> On Wednesday 03 March 2004 11:50 pm, Beau E. Cox wrote:
> > Hello folks,
> >
> > I noticed changed in DBD::DBM in the latest svn DBI source.
> >
> > When I try to test DBI (make is fine):
> >
> [TEST ERRORS]
> 
> Here is what I did to clear the problen on my machine:
> 
> 1) added dbm to DBI registry (as noted in a prior reply).
> 2) patched DBM.pm to allow additions of private attribs:
> 
> --- trunk/lib/DBD/DBM.pm      2004-03-03 22:03:28.000000000 -1000
> +++ test-trunk/lib/DBD/DBM.pm 2004-03-04 01:02:38.000000000 -1000
> @@ -113,9 +113,9 @@
>                  #
>                  $var = 'dbm_' . $var unless $var =~ /^dbm_/
>                                       or     $var eq 'f_dir';
> -                if (!$this->{f_valid_attrs}->{$var}) {
> -                    die "Invalid attribute in connect: '$var'!\n"
> -             }
> +                #if (!$this->{f_valid_attrs}->{$var}) {
> +                #    die "Invalid attribute in connect: '$var'!\n"
> +             #}
>               $this->{$var} = $val;
>           }
>       }

Here's a better way (driver authors please note):

-                # in the connect string the attr names
-                # can either have dbm_ (or foo_) prepended or not
-                # this will add the prefix if it's missing
-                #
-                $var = 'dbm_' . $var unless $var =~ /^dbm_/
-                                     or     $var eq 'f_dir';
-                if (!$this->{f_valid_attrs}->{$var}) {
-                    die "Invalid attribute in connect: '$var'!\n"
-               }
-               $this->{$var} = $val;

+               # Add dbm_ prefix to attributes that need it
+               # (attributes for DBD::Foo in the Driver DSN portion
+               # of the DSN string are allowed to skip the "foo_" prefix)
+               $var = 'dbm_' . $var if !$valid_attrs->{$var}
+                                    &&  $valid_attrs->{"dbm_$var"};
+
+               # place the attribute in $attr (possibly replacing an exiting value)
+               # so DBI->connect will then call our STORE on it for us.
+               # Our STORE method (inherited from DBD::File's) should validate it
+               $attr->{$var} = $val;

That's a better approach I think. I've not checked the test to see
that they're exercising this code though.

> 3) (optional) got rid of annoying 'undefined var...' msgs in t/50dbm.t:
> 
> --- trunk/t/50dbm.t   2004-03-03 22:03:27.000000000 -1000
> +++ test-trunk/t/50dbm.t      2004-03-04 01:06:18.000000000 -1000
> @@ -29,10 +29,10 @@
>  #
>  
>  printf "\n%s %s\n%s %s\n%s %s\n%s %s\n",
> -         'DBD::DBM'       , $dbh->{Driver}->{Version}
> -       , 'DBD::File'      , $dbh->{Driver}->{file_version}
> -       , 'DBI::SQL::Nano' , $dbh->{Driver}->{nano_version}
> -       , 'SQL::Statement' , $dbh->{Driver}->{statement_version}
> +         'DBD::DBM'       , $dbh->{Driver}->{Version} || 'undef'
> +       , 'DBD::File'      , $dbh->{Driver}->{file_version} || 'undef'
> +       , 'DBI::SQL::Nano' , $dbh->{Driver}->{nano_version} || 'undef'
> +       , 'SQL::Statement' , $dbh->{Driver}->{statement_version} || 'undef'
>         ;

Thanks, applied.

Tim.

Reply via email to