Yep (American spelling). Here's the new DBD::DBM::db::STORE. I am *not* going to implement the validity checks in File yet because I'm not yet sure what that would break for existing drivers that subclass it.... the other shoe drops. My suggestion above is probably bad because the driver may need to check the *value* as well as the attribute so it should happen in the driver, not in DBD::File.
Not just "check the value" but also possibly so something other than just simply store the value. Similarly for FETCH, some values may need to be created dynamically.
I'll commit the svn changes for DBD::DBM and DBD::File in a moment and also send you a new test script which has added checks that DBD::DBM allows setting of valid dbm_ attributes and doesn't allow setting of invalid dbm_ attributes.
-- excerpt from DBD::DBM --
# the ::db::STORE method is what gets called when you set
# a lower-cased database handle attribute such as $dbh->{somekey}=$someval;
#
# STORE should check to make sure that "somekey" is a valid attribute name
# but only if it is really one of our attributes (starts with dbm_ or foo_)
# You can also check for valid values for the attributes if needed
# and/or perform other operations
#
sub STORE ($$$) {
my ($dbh, $attrib, $value) = @_;# use DBD::File's STORE unless its one of our own attributes # return $dbh->SUPER::STORE($attrib,$value) unless $attrib =~ /^dbm_/;
# throw an error if it has our prefix but isn't a valid attr name
#
if ( $attrib ne 'dbm_valid_attrs' # gotta start somewhere :-)
and !$dbh->{dbm_valid_attrs}->{$attrib} ) {
return $dbh->set_err( 1,"Invalid attribute '$attrib'!");
}
else { # check here if you need to validate values
# or conceivably do other things as well
#
$dbh->{$attrib} = $value;
return 1;
}
}-- end excerpt --
-- Jeff
