[Bast-commits] r5737 -
DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Wed Mar 11 23:23:18 GMT 2009
Author: ribasushi
Date: 2009-03-11 23:23:18 +0000 (Wed, 11 Mar 2009)
New Revision: 5737
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/Accessor.pm
Log:
Properly returb undef/null on single rewlationship accessor
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/Accessor.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/Accessor.pm 2009-03-11 19:25:25 UTC (rev 5736)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Relationship/Accessor.pm 2009-03-11 23:23:18 UTC (rev 5737)
@@ -31,18 +31,12 @@
$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, {}, {});
+ return $val unless $val; # $val instead of undef so that null-objects can go through
- # 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;
}
};
More information about the Bast-commits
mailing list