From: Matt S Trout Date: Mon, 24 Oct 2005 16:16:49 +0000 (+0000) Subject: Tweak to ResultSet to fix prefetch for nonexistant might_have X-Git-Tag: v0.05005~192 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7cd300ea95a8d07f8c3af04c266007e4fe0afa43;p=dbsrgits%2FDBIx-Class.git Tweak to ResultSet to fix prefetch for nonexistant might_have --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 3cc8caa..4f702fa 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -135,7 +135,10 @@ sub _construct_object { unless defined $rel_obj->{attrs}{accessor}; if ($rel_obj->{attrs}{accessor} eq 'single') { foreach my $pri ($rel_obj->{class}->primary_columns) { - next PRE unless defined $fetched->get_column($pri); + unless (defined $fetched->get_column($pri)) { + undef $fetched; + last; + } } $new->{_relationship_data}{$pre} = $fetched; } elsif ($rel_obj->{attrs}{accessor} eq 'filter') { diff --git a/t/run/16joins.tl b/t/run/16joins.tl index 3f7e596..98a8515 100644 --- a/t/run/16joins.tl +++ b/t/run/16joins.tl @@ -115,7 +115,7 @@ my @cd = $rs->all; is($cd[0]->title, 'Spoonful of bees', 'First record returned ok'); -ok(!exists $cd[0]->{_relationship_data}{liner_notes}, 'No prefetch for NULL LEFT JOIN'); +ok(!defined $cd[0]->liner_notes, 'No prefetch for NULL LEFT join'); is($cd[1]->{_relationship_data}{liner_notes}->notes, 'Buy Whiskey!', 'Prefetch for present LEFT JOIN');