Remove no longer needed try{} block in related rel instantiation
Peter Rabbitson [Wed, 24 Jun 2015 11:04:28 +0000 (13:04 +0200)]
This try{} is no longer necessary after 3b4c4d72, but was missed due its
function not being readily apparent. The only known case where this
exception could be raised and be silenced is if an uninserted object had
some filter relations populated directly via {_inflated_column} *before*
related_resultset() has ever been called. This would result in a cascade
of failures during the relationship resolution, and bubble up here.

Starting with 3b4c4d72 the empty related resultset is instantiated ahead
of time, and everything works properly from there on.

In the unlikely case this does cause issues downstream, a way will be
found to address this ( worst case scenario by reintroducing the try{} )

lib/DBIx/Class/Relationship/Base.pm

index 1587403..c7daf57 100644 (file)
@@ -523,15 +523,7 @@ sub related_resultset {
       if (@_ > 1 && (@_ % 2 == 1));
     my $query = ((@_ > 1) ? {@_} : shift);
 
-    # condition resolution may fail if an incomplete master-object prefetch
-    # is encountered - that is ok during prefetch construction (not yet in_storage)
-    my ($cond, $is_crosstable) = try {
-      $rsrc->_resolve_condition( $rel_info->{cond}, $rel, $self, $rel )
-    }
-    catch {
-      $self->throw_exception ($_) if $self->in_storage;
-      UNRESOLVABLE_CONDITION;  # RV, no return()
-    };
+    my ($cond, $is_crosstable) = $rsrc->_resolve_condition( $rel_info->{cond}, $rel, $self, $rel );
 
     # keep in mind that the following if() block is part of a do{} - no return()s!!!
     if ($is_crosstable and ref $rel_info->{cond} eq 'CODE') {