From: Peter Rabbitson Date: Wed, 11 Mar 2009 23:23:18 +0000 (+0000) Subject: Properly returb undef/null on single rewlationship accessor X-Git-Tag: v0.08100~46 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e0d8aec0dea8582d453b56f238d1bbae3622b95f;p=dbsrgits%2FDBIx-Class.git Properly returb undef/null on single rewlationship accessor --- diff --git a/lib/DBIx/Class/Relationship/Accessor.pm b/lib/DBIx/Class/Relationship/Accessor.pm index 02f7db5..065cf69 100644 --- a/lib/DBIx/Class/Relationship/Accessor.pm +++ b/lib/DBIx/Class/Relationship/Accessor.pm @@ -31,17 +31,11 @@ sub add_relationship_accessor { $rel_info->{cond}, $rel, $self ); if ($rel_info->{attrs}->{undef_on_null_fk}){ - return unless ref($cond) eq 'HASH'; - return if grep { not defined } values %$cond; + return undef unless ref($cond) eq 'HASH'; + return undef if grep { not defined $_ } values %$cond; } my $val = $self->find_related($rel, {}, {}); - - # this really should have been: - # return $val unless $val - # however someone might already be relying on return() as in: - # my @things = map { $_->might_have_acc } ($rs->all) - # thus keeping the quirky behavior - return unless defined $val; + return $val unless $val; # $val instead of undef so that null-objects can go through return $self->{_relationship_data}{$rel} = $val; }