From: Guillermo Roditi Date: Wed, 10 Dec 2008 01:28:10 +0000 (+0000) Subject: fix for bug. all tests seem to pass, we still need a new test and more research X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=84a1c93f976a27eb0d89ccbfecd6beabeeeecb21;p=dbsrgits%2FDBIx-Class-Historic.git fix for bug. all tests seem to pass, we still need a new test and more research --- diff --git a/lib/DBIx/Class/Relationship/Accessor.pm b/lib/DBIx/Class/Relationship/Accessor.pm index fb15f10..d9c24a4 100644 --- a/lib/DBIx/Class/Relationship/Accessor.pm +++ b/lib/DBIx/Class/Relationship/Accessor.pm @@ -18,6 +18,7 @@ sub add_relationship_accessor { my ($class, $rel, $acc_type) = @_; my %meth; if ($acc_type eq 'single') { + my $rel_cond = $class->relationship_info($rel)->{cond}; $meth{$rel} = sub { my $self = shift; if (@_) { @@ -26,6 +27,10 @@ sub add_relationship_accessor { } elsif (exists $self->{_relationship_data}{$rel}) { return $self->{_relationship_data}{$rel}; } else { + my $cond = $self->result_source->resolve_condition( + $rel_cond, $rel, $self + ); + return if grep { not defined } values %$cond; my $val = $self->find_related($rel, {}, {}); return unless $val; return $self->{_relationship_data}{$rel} = $val;