fixed up the replication test, added some tests for the dbd::multi problem of null...
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / ResultClass / HashRefInflator.pm
index 9a2c8eb..4aa362a 100644 (file)
@@ -1,5 +1,8 @@
 package DBIx::Class::ResultClass::HashRefInflator;
 
+use strict;
+use warnings;
+
 =head1 NAME
 
 DBIx::Class::ResultClass::HashRefInflator
@@ -23,13 +26,13 @@ There are two ways of using this class.
 =item *
 
 Specify C<< $rs->result_class >> on a specific resultset to affect only that
-resultser (and any chained off of it); or
+resultset (and any chained off of it); or
 
 =item *
 
 Specify C<< __PACKAGE__->result_class >> on your source object to force all
 uses of that result source to be inflated to hash-refs - this approach is not
-recomended
+recommended.
 
 =back
 
@@ -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
     };