trap unresolvable conditions due to incomplete relationship specification
Peter Rabbitson [Fri, 19 Feb 2010 09:07:40 +0000 (09:07 +0000)]
lib/DBIx/Class/Relationship/Base.pm

index daf853d..1027509 100644 (file)
@@ -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) {