I am having trouble retrieving a field "through" a relationship. I'll add detail below, but what I'd like to do is this:

$player_static->player_data_currs->team_libl;
(I know this must be answered in the DBIx::Class::ResultSet documentation, but I am somehow blind to it.) The team_libl field exists in PlayerDataCurr and player_data_currs is defined in Schema::Result::PlayerDataStatic this way:
__PACKAGE__->has_many( "player_data_currs", "LIBL::Schema::Result::PlayerDataCurr", { "foreign.id_static" => "self.id" }, { cascade_copy => 0, cascade_delete => 0 }, );
Searching using the player_data_currs relation works. For example, this returns a resultset:
my $roster_rs = $player_static_model->search( { 'player_data_currs.team_libl' => \'IS NOT NULL', }, { prefetch => [ 'player_data_currs', ], }, ); say scalar $roster_rs->all;
Using the search above, this will print a list of hash refs:
foreach my $player_static ($roster_rs->all){ say $player_static->player_data_currs; }
Like this:
LIBL::Schema::Result::PlayerDataCurr=HASH(0x39b40b8) LIBL::Schema::Result::PlayerDataCurr=HASH(0x39b2010) LIBL::Schema::Result::PlayerDataCurr=HASH(0x39b40e8)
But this reports an error:
foreach my $player_static ($roster_rs->all){ say $player_static->player_data_currs->team_libl; }
Here's the error message:
Can't locate object method "team_libl" via package "DBIx::Class::Resul +tSet" at /home/varanasi/Documents/80-004 LIBL-14/bin/monks.pl line 69 +.


In reply to Trouble Getting Field Through A DBIx::Class::ResultSet Relation by varanasi

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.