[Dbix-class] DBIx::Class::ResultSet / resolve_prefetch() / Use of uninitialized value in pattern match

Chisel Wright chisel at herlpacker.co.uk
Wed Jul 30 11:17:59 BST 2008


On Wed, Jul 30, 2008 at 10:52:49AM +0100, Matt S Trout wrote:
> Right, but is it a bug that we don't make undef alias become '' or is
> it a bug that we don't die on it?
> 
> Assuming there's nothing using it in undef mode I think for the moment we
> should just die() when not given an alias.
> 
> It's maybe arguable that you should have '' mean "don't add an alias at all"
> but DBIC will never need that feature so I'd rather we left it for the moment.

I'm not entirely sure what _should_ happen.

As far as I can tell, there's no obvious reason why

  my @columns = $source->resolve_prefetch( { cd => 'artist' } );

should spew warnings.

To me it looks like a harmless call to make. I'm not sure what "alias"
is, or where is should be set, and what to.


This line is the one that has problems when $alias is undef:

  my $as_prefix = ($alias =~ /^.*?\.(.+)$/ ? $1.'.' : '');

To me it seems that $alias is allowed to be nothing, but wasn't checked
for defined-ness before using in a m//

The overall behaviour with/without my patch is the same, you just don't
get logs full of "unitialised value" warnings with it.

Obviously as author and maintainer, it's your call, but $alias is
undefined in some cases.
-- 
Chisel Wright
e: chisel at herlpacker.co.uk
w: http://www.herlpacker.co.uk/

  You can simulate the effect of buying a boat by standing in
  a cold shower while tearing up twenty pound notes...   



More information about the DBIx-Class mailing list