[Dbix-class] how to handle tables with multi column foreign keys

Daniel Westermann-Clark daniel at acceleration.net
Mon May 1 21:33:39 CEST 2006


On 2006-05-01 11:04:45 -0700, John Napiorkowski wrote:
> __PACKAGE__->belongs_to('folders' 		=>
> 'talentspace_portal::Schema::db::bookmarks::folders');

Try something like:

__PACKAGE__->belongs_to(
    folders => 'talentspace_portal::Schema::db::bookmarks::folders',
    {
        'foreign.folder_id'   => 'self.folder_id',
        'foreign.document_id' => 'self.document_id',
    },
);

> Which is working fine for tables that have single column foriegn
> keys, but with this I get an error stating that it can't infer the
> correct table.

DBIx::Class does not attempt to guess the correct referents for
multi-column foreign keys (order could be different, etc.).

> I can see there is quite a bit of information in the docs for
> DBIx::Class:Relationship::Base, but to be honest I'm just not
> getting it.

I've added an example:

http://dev.catalyst.perl.org/trac/bast/browser/trunk/DBIx-Class/lib/DBIx/Class/Relationship/Base.pm

but suggestions for improvement (especially from a new user's
perspective) are appreciated.

-- 
Daniel Westermann-Clark



More information about the Dbix-class mailing list