From: Marcus Ramberg Date: Mon, 13 Mar 2006 13:00:24 +0000 (+0000) Subject: fix for hm prefetch and test. X-Git-Tag: v0.06000~60^2~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=62e87ea8a04936c46ba9671cc95a81ca674d999b;p=dbsrgits%2FDBIx-Class.git fix for hm prefetch and test. --- diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index fd3ad13..85a0551 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -318,7 +318,7 @@ sub inflate_result { $pre_source, @{$pre_rec})); } $new->related_resultset($pre)->set_cache(\@pre_objects); - } else { + } elsif (defined $pre_val->[0]) { my $fetched; unless ($pre_source->primary_columns == grep { exists $pre_val->[0]{$_} and !defined $pre_val->[0]{$_} } $pre_source->primary_columns) diff --git a/t/run/23cache.tl b/t/run/23cache.tl index 6548465..45e638c 100644 --- a/t/run/23cache.tl +++ b/t/run/23cache.tl @@ -3,7 +3,7 @@ my $schema = shift; eval "use DBD::SQLite"; plan skip_all => 'needs DBD::SQLite for testing' if $@; -plan tests => 14; +plan tests => 15; my $rs = $schema->resultset("Artist")->search( { artistid => 1 } @@ -73,6 +73,14 @@ $rs = $schema->resultset("Artist")->search( }, } ); +{ +$schema->resultset("Artist")->create({artistid=>4,name=>qq{Humoungous Hamsters}}); +my $artist = $schema->resultset("Artist")->search( + { artistid => 4 },{prefetch=>[qw/cds/]} +)->first; + +is($artist->cds, 0, 'No cds for this artist'); +} # SELECT count for nested has_many prefetch unlink 't/var/dbic.trace' if -e 't/var/dbic.trace';