[Dbix-class] Patch submission: Relationship Accessor for null pattern compatibility

Peter Rabbitson rabbit+dbic at rabbit.us
Wed Mar 11 09:45:02 GMT 2009


David Ihnen wrote:
> When working with the null pattern classes from Mr. Rabbitson, I
> discovered this slight ommission that results in getting an undefined,
> when you're actually wanting a null.  That is, even when something is
> not true, I still want it!  It should be entirely backwards compatible
> with existing code.  Perhaps it can it make it into the next version?
> 
> Hopefully,
> 
> David
> 
> 
> 
> --- /usr/share/perl5/DBIx/Class/Relationship/Accessor.pm    2009-03-10
> 17:19:39.000000000 -0700
> +++ DBIx/Class/Relationship/Accessor.pm    2009-03-10 17:13:52.000000000
> -0700
> @@ -25,7 +25,7 @@
>         return $self->{_relationship_data}{$rel};
>       } else {
>         my $val = $self->find_related($rel, {}, {});
> -        return unless $val;
> +        return $val unless $val;
>         return $self->{_relationship_data}{$rel} = $val;
>       }
>     };
> 

Thank you for spotting this omission. Unfortunately your patch can not be
applied, as it changes $row->relaccessor behavior in a subtle way. Here is
what was committed instead, which should solve the problem equally well:

http://dev.catalyst.perl.org/svnweb/bast/revision/?rev=5734

Cheers



More information about the DBIx-Class mailing list