Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: dbix: Can't handle this yet error (joining using or?)

by uG (Scribe)
on Sep 13, 2008 at 17:12 UTC ( #711143=note: print w/ replies, xml ) Need Help??


in reply to Re: dbix: Can't handle this yet error (joining using or?)
in thread dbix: Can't handle this yet error (joining using or?)

Preserving the direction isn't important (yet). id1 will always be the one to have 'created' the trade, so if I check the nation's trade->id1 against user.id I can figure out the direction. Although after switching the brackets to curley brackets (how I missed this I dont know haha) I get this instead:

"Can't locate object method "nation" via package "DBIx::Class::ResultS +et"
'nation' is defined via a belongs_to in the Trades schema. This makes me think that you are correct about not being able to use belongs_to for more than one owner.


Comment on Re^2: dbix: Can't handle this yet error (joining using or?)
Download Code
Re^3: dbix: Can't handle this yet error (joining using or?)
by juster (Friar) on Sep 13, 2008 at 21:08 UTC

    After getting some sleep I realized the most obvious answer to the problem would be to have each Trade belong to two Nations.

    package Game::DB::Schema:Trades; __PACKAGE__->belongs_to( creator => 'Game::DB::Schema::Nation', { 'foreign.id' => 'self.id1', }, ); __PACKAGE__->belongs_to( acceptor => 'Game::DB::Schema::Nation', { 'foreign.id' => 'self.id2', }, );

    At the top of DBIx::Class::Relationship in the Synopsis there is even an example of this showing a many-to-many relationship which you could probably even implement if you wanted to.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://711143]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (19)
As of 2014-10-30 15:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (208 votes), past polls