You are using the wrong backets for your last arguments to has_many and belongs_to. Using [ ] creates an array reference and the docs ask for a hash reference ({ }).

You can also save typing by using the accessor methods instead of using empty searche_relateds like so:

my $resource_rs = $nation_rs->trades->nation->resources;

Assuming there is a "resources" relation inside your nation class that you are omitting.

After posting the above and rereading your post I found what may be a problem with the schema. I'm not sure if a belongs_to relationship can be used to give multiple results. At least when I have used it, and in all examples I've found, belongs_to is used to return the owner instance (row) of the owner class (table).

Told another way, the nation has many trades. Sure that's nice. But can the trade belong to many nations and have more than one owner? I would't think so, at least not in the context of DB relationships.

I would imagine a trade has many nations making this a many to many relationship but I can't think of how to preserve who traded what in what direction. Maybe someone with more DB experience can help where I've fallen short. Assuming, of course, that this is even an error!


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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.