From: Matt S Trout Date: Fri, 18 Jan 2008 13:03:08 +0000 (+0000) Subject: added strict and warnings to HashRefInflator, fixed inflation for empty has_many... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=833045455985bf452c5a4817d238444643b40bc7;p=dbsrgits%2FDBIx-Class-Historic.git added strict and warnings to HashRefInflator, fixed inflation for empty has_many rels --- diff --git a/lib/DBIx/Class/ResultClass/HashRefInflator.pm b/lib/DBIx/Class/ResultClass/HashRefInflator.pm index 6ad22ad..4aa362a 100644 --- a/lib/DBIx/Class/ResultClass/HashRefInflator.pm +++ b/lib/DBIx/Class/ResultClass/HashRefInflator.pm @@ -1,5 +1,8 @@ package DBIx::Class::ResultClass::HashRefInflator; +use strict; +use warnings; + =head1 NAME DBIx::Class::ResultClass::HashRefInflator @@ -61,7 +64,7 @@ sub mk_hash { # related sources. # to avoid emtpy has_many rels contain one empty hashref - return if (not keys %$me); + return undef if (not keys %$me); my $def; @@ -71,13 +74,14 @@ sub mk_hash { last; } } - return unless $def; + return undef unless $def; return { %$me, map { ( $_ => - ref($rest->{$_}[0]) eq 'ARRAY' ? [ map { mk_hash(@$_) } @{$rest->{$_}} ] - : mk_hash( @{$rest->{$_}} ) + ref($rest->{$_}[0]) eq 'ARRAY' + ? [ grep defined, map mk_hash(@$_), @{$rest->{$_}} ] + : mk_hash( @{$rest->{$_}} ) ) } keys %$rest };