[CDBI] Patch to Class::DBI.pm to avoid warning on stringification

Dave Howorth dhoworth at mrc-lmb.cam.ac.uk
Wed Nov 9 09:26:06 GMT 2005


On Tue, 2005-11-08 at 11:15 -0600, Ken Youens-Clark wrote:
> Hi,
> 
> I'm getting the following error filling up my Apache logs:
> 
> Use of uninitialized value in join or string at /usr/local/lib/perl5/ 
> site_perl/5.8.6/Class/DBI.pm line 47.

Why is it happening? The full code of that sub is:

sub stringify_self {
	my $self = shift;
	return (ref $self || $self) unless $self;    # empty PK
	my @cols = $self->columns('Stringify');
	@cols = $self->primary_columns unless @cols;
	return join "/", $self->get(@cols);
}

which implies that either you have undefined columns in your primary
keys or you have explicitly told it to stringify undefined values??

Cheers, Dave

> This happens on the stringification of classes.  The following patch  
> quiets things down:
> 
> $ diff DBI.pm.orig DBI.pm
> 47c47
> <       return join "/", $self->get(@cols);
> ---
>  >       return join "/", map { defined $_ ? $_ : '' } $self->get 
> (@cols);
> 
> Does that look reasonable?







More information about the ClassDBI mailing list