X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship%2FBase.pm;h=f78bb6b4a3fbc25441658b7347609e47b7280b25;hb=c4d239930f5d96be7ddccdb59ff07ff1bd43698d;hp=9ad86d6cb8c1c8e2dbef68c4909a7faa675e345b;hpb=370f2ba2727791641c350a20e4fd09469503dbae;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 9ad86d6..f78bb6b 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -67,7 +67,9 @@ Each key-value pair provided in a hashref will be used as Ced conditions. To add an Ced condition, use an arrayref of hashrefs. See the L documentation for more details. -In addition to standard result set attributes, the following attributes are also valid: +In addition to the +L, +the following attributes are also valid: =over 4 @@ -186,9 +188,22 @@ sub related_resultset { if (@_ > 1 && (@_ % 2 == 1)); my $query = ((@_ > 1) ? {@_} : shift); - my $cond = $self->result_source->resolve_condition( + my $source = $self->result_source; + my $cond = $source->resolve_condition( $rel_obj->{cond}, $rel, $self ); + if ($cond eq $DBIx::Class::ResultSource::UNRESOLVABLE_CONDITION) { + my $reverse = $source->reverse_relationship_info($rel); + foreach my $rev_rel (keys %$reverse) { + if ($reverse->{$rev_rel}{attrs}{accessor} eq 'multi') { + $attrs->{related_objects}{$rev_rel} = [ $self ]; + Scalar::Util::weaken($attrs->{related_object}{$rev_rel}[0]); + } else { + $attrs->{related_objects}{$rev_rel} = $self; + Scalar::Util::weaken($attrs->{related_object}{$rev_rel}); + } + } + } if (ref $cond eq 'ARRAY') { $cond = [ map { if (ref $_ eq 'HASH') { @@ -202,7 +217,7 @@ sub related_resultset { $_; } } @$cond ]; - } else { + } elsif (ref $cond eq 'HASH') { foreach my $key (grep { ! /\./ } keys %$cond) { $cond->{"me.$key"} = delete $cond->{$key}; }