[Dbix-class] Re: Problem with non-PK FK's

Brandon Black blblack at gmail.com
Wed Dec 14 05:09:29 CET 2005


On 12/13/05, Brandon Black <blblack at gmail.com> wrote:
> I'll see if I can't find the exact source of the issue (or maybe even
> a fix for it) this evening, but in the meantime I thought I'd report
> that it exists.
>

Update:

The problem technically lies in DBIx::Class::Loader::*.  You can
manually make these relationships work with the syntax:

MusicDB::AlbumArtwork->belongs_to( 'album_other_id' =>
'MusicDB::Albums', { "foreign.other_id" => "self.album_other_id" } );

which apparently overrides the default use of the foreign primary key.
 The issue is that under DBIx::Class::Loader, if the REFERENCES
constraint mentions a specific foreign column, that column name is
ignored and the foreign primary key is used instead.  The fix would
probably involve code in
DBIx::Class::Loader::Generic->_belongs_to_many(), and
DBIx::Class::Loader::[dbvendors]->_relationships().  I'm just a little
unsure of exactly how to implement it and not disturb the rest of the
surrounding design too much yet.  I may yet come up with a sane-ish
patch tonight though.

-- Brandon



More information about the Dbix-class mailing list