On Sat, Dec 12, 2009 at 11:21 AM, Peter Rabbitson <[email protected]> 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:
z...@zby:~/progs/tmp$ perl a.pl
Can't locate object method "account" via package
"The::Schema::Customer" at a.pl line 35.
z...@zby:~/progs/tmp$
What am I missing?
--
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]