Hi folks,

I have a table which has two columns referencing the same class, something like this:

"id, user1_id, user2_id"

Both, user1_id and user2_id, contain User object ids.

Unfortunately I'm unable to set up two independent belongs_to relationships. I tried
this in my UserRelation class:

__PACKAGE__->belongs_to( 'requestor', 'My::Schema::User', { 'foreign.id' => 'self.user1_id' }, { proxy => [ qw/id username/ ] } ); __PACKAGE__->belongs_to( 'receiver', 'My::Schema::User', { 'foreign.id' => 'self.user2_id' }, { proxy => [ qw/id username/ ] } );

Depending on the order of these statements I get different results.

My User class has the following has_many relations:

__PACKAGE__->has_many( requested => 'My::Schema::UserRelation', { 'foreign.user1_id' => 'self.id' } ); __PACKAGE__->has_many( received => 'My::Schema::UserRelation', { 'foreign.user2_id' => 'self.id' } );

$user->requested should return user2_id User objects, whereas $user- >received should return user1_id User objects. But this doesn't work as intended. I suppose that proxy is unable to determine the appropriate User object.

It's probably just me messing things up, but maybe there's some switch which allows me to do what I want.

Thanks!

--Tobias

_______________________________________/\____ _ .  .
+ web ::::::: http://www.funkreich.de
+ last.fm ::: http://www.last.fm/user/soulchild77
----------------------------------------------- -- -  -



_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/

Reply via email to