Re: calling 'has_a' on foreign key that is also a primary key causes intermittant error.

[prev] [thread] [next] [Date index for 2005/02/08]

From: Perrin Harkins
Subject: Re: calling 'has_a' on foreign key that is also a primary key causes intermittant error.
Date: 12:12 on 08 Feb 2005
Chris Soanes wrote:
> when I create the subscriber_gateways class, if I call has_a on the 
> primary key, it causes intermittant faults when accessing the class 
> later on, in that, while search and retrieve succeed, calling the 
> mgcp_domain_name accessor produces the following error:
> 
> Can't bind a reference (FENS::BBV::gateways=HASH(0x64b6e4)) at 
> /opt/perl5.8.6/lib/site_perl/5.8.6/DBIx/ContextualFetch.pm line 51.
> 
> I've gotten round it for now by not calling has_a on the foreign key, 
> but I'm wondering if there's another way?

There is at least one other problem I know of with this scenario.  If 
you create a "gateways" object with create(), and then call the has_a() 
method, it will give you back the ID instead of inflating an object.

At the moment, I work around these problems by making my own method in 
place of has_a():

sub subscriber {
     my $self = shift;
     return My::SubscriberGateways->retrieve( $self->name() );
}

You could also try using might_have in this case.

- Perrin

Re: calling 'has_a' on foreign key that is also a primary key causes intermittant error.
Perrin Harkins 12:12 on 08 Feb 2005

Generated at 10:21 on 11 Feb 2005 by mariachi v0.52