From: Peter Rabbitson Date: Fri, 19 Feb 2010 09:07:40 +0000 (+0000) Subject: trap unresolvable conditions due to incomplete relationship specification X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d419ded691dc92658a0fee6658e475fa58b31e3a;p=dbsrgits%2FDBIx-Class-Historic.git trap unresolvable conditions due to incomplete relationship specification --- diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index daf853d..1027509 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -200,9 +200,15 @@ sub related_resultset { my $query = ((@_ > 1) ? {@_} : shift); my $source = $self->result_source; - my $cond = $source->_resolve_condition( - $rel_info->{cond}, $rel, $self - ); + + # condition resolution may fail if an incomplete master-object prefetch + # is encountered + my $cond = + eval { $source->_resolve_condition( $rel_info->{cond}, $rel, $self ) } + || + $DBIx::Class::ResultSource::UNRESOLVABLE_CONDITION + ; + if ($cond eq $DBIx::Class::ResultSource::UNRESOLVABLE_CONDITION) { my $reverse = $source->reverse_relationship_info($rel); foreach my $rev_rel (keys %$reverse) {