From: Peter Rabbitson <ribasushi@cpan.org>
Date: Wed, 11 Mar 2009 09:43:40 +0000 (+0000)
Subject: Allow accessors type single to return defined but false objects (needed for null... 
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cde1c1e1c39b895f731274fd40a9bf60f2f1f092;p=dbsrgits%2FDBIx-Class-Historic.git

Allow accessors type single to return defined but false objects (needed for null-pattern style components)
---

diff --git a/lib/DBIx/Class/Relationship/Accessor.pm b/lib/DBIx/Class/Relationship/Accessor.pm
index 6ec2f25..02f7db5 100644
--- a/lib/DBIx/Class/Relationship/Accessor.pm
+++ b/lib/DBIx/Class/Relationship/Accessor.pm
@@ -35,7 +35,14 @@ sub add_relationship_accessor {
           return if grep { not defined } values %$cond;
         }
         my $val = $self->find_related($rel, {}, {});
-        return unless $val;
+
+        # 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 $self->{_relationship_data}{$rel} = $val;
       }
     };