Re: [Maypole-dev] Bug in Maypole::Model::CDBI ?

From: Simon Flack (sf at flacks.net)
Date: Tue Dec 07 2004 - 18:27:40 GMT


David Baird wrote:
> Hi,
>
> Maypole::Model::CDBI::related returns a list, not a hashref. This patch
> seems to do the right thing, but this is at the limit of my CDBI-fu so
> treat with caution.

On the face of it this looks ok, but I really need to have a closer look
at meta_info(), and a quick test before commiting that.

While we're at it, should related() return info about has_a relationships?

> Cheers,
>
> d.
>
>
> --- /usr/lib/perl5/site_perl/5.6.1/Maypole/Model/CDBI.pm Fri Oct
> 15 23:01:22 2004
> +++ Maypole-Model-CDBI/lib/Maypole/Model/CDBI.pm Tue Dec 7
> 14:08:18 2004
> @@ -80,8 +80,13 @@
>
> sub related_class {
> my ( $self, $r, $accessor ) = @_;
> - my $related = $self->related->{$accessor};
> - if ( my $mapping = $related->{args}->{mapping} ) {
> +
> + my $related = $self->meta_info( has_many => $accessor ) ||
> + $self->meta_info( has_a => $accessor ) ||
> + return;
> +
> + my $mapping = $related->{args}->{mapping};
> + if ( @$mapping ) {
> return $related->{foreign_class}->meta_info('has_a')->{
> $$mapping[0] }
> ->{foreign_class};
> }

--simonflk

_______________________________________________
maypole-dev mailing list
maypole-dev at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole-dev



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT