On Thu, Dec 16, 2004 at 03:19:57PM +0100, Steffen Goeldner wrote: > Tim Bunce wrote: > > > [...] > >+ # add driver prefix to attribute name if it doesn't have it > >already > >+ $attr_name = $driver_prefix.$attr_name > >+ unless $attr_name =~ /^$driver_prefix/o; > >+ > >+ # Store attribute into %$attr, replacing any existing value. > >+ # The DBI will STORE() these into $dbh after we've connected > >+ $attr->{$attr_name} = $attr_value; > > What if $attr_name is in mixed case? DBI::DBD says: > > Note the prefix drv_ in the attribute names: it is required that > your private attributes are lowercased and use such a prefix.
Actually it's only the first letter that matters (so foo_Bar is okay, if you like that kind of thing :) I've changed the text to read: : Note the prefix I<drv_> in the attribute names: it is required that : all your private attributes use a lowercase prefix unique to your driver. : The DBI contains a registry of known driver prefixes and may one day : warn about unknown attributes that don't have a registered prefix. > Is STORE() responsible for checking/changing this or should the > connect() code above handle this? I'm not quite sure what you're asking there. I presume you asking about any invalid/misspelt driver-private attribute not just mixed case ones. The example STORE in DBI::DBD docs is: sub STORE { my ($dbh, $attr, $val) = @_; if ($attr eq 'AutoCommit') { # AutoCommit is currently the only standard attribute we have # to consider. if (!$val) { die "Can't disable AutoCommit"; } return 1; } if ($attr =~ m/^drv_/) { # Handle only our private attributes here # Note that we could trigger arbitrary actions. # Ideally we should catch unknown attributes. $dbh->{$attr} = $val; # Yes, we are allowed to do this, return 1; # but only for our private attributes } # Else pass up to DBI to handle for us $dbh->SUPER::STORE($attr, $val); } That'll work fine though, as it says, "Ideally we should catch unknown attributes." Having a hash of valid attributes would make that easy. Tim.