[Dbix-class] BUG? Unable to resolve relationship

Zbigniew Lukasiak zzbbyy at gmail.com
Sun Dec 13 08:17:33 GMT 2009

On Sat, Dec 12, 2009 at 11:21 AM, Peter Rabbitson <rabbit+dbic at rabbit.us> wrote:
> Zbigniew Lukasiak wrote:
>> One additional question - what is the relation between 'belongs_to'
>> and 'might_have' etc and 'add_relationship'?  I always thought that
>> the first ones are only sugar for the last.  But unfortunately
>> 'add_relationship' does not add an appropriate methods to the row
>> class.
> It does, you're just looking at the wrong one. Here is the rough chain
> of events:
> ::Relationship::HasMany::has_many()
>  ->  ::ResultSourceProxy::add_relationship()
>    -> ::ResultSource::add_relationship()
>    -> ::Relationship::ProxyMethods::register_relationship()
>    -> ::Relationship::Accessor::register_relationship()
>      -> ::Relationship::Accessor::add_relationship_accessor()

How should I invoke it to add them?  When I change the line in question to:

The::Schema::Customer->add_relationship( "account", "The::Schema::Account",
    { "foreign.id" => "self.account_id" } );

and run the program I get:

zby at zby:~/progs/tmp$ perl a.pl
Can't locate object method "account" via package
"The::Schema::Customer" at a.pl line 35.
zby at zby:~/progs/tmp$

What am I missing?

Zbigniew Lukasiak

More information about the DBIx-Class mailing list