I am having trouble retrieving a field "through" a relationship. I'll add detail below, but what I'd like to do is this:
(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:$player_static->player_data_currs->team_libl;
Searching using the player_data_currs relation works. For example, this returns a resultset:__PACKAGE__->has_many( "player_data_currs", "LIBL::Schema::Result::PlayerDataCurr", { "foreign.id_static" => "self.id" }, { cascade_copy => 0, cascade_delete => 0 }, );
Using the search above, this will print a list of hash refs:my $roster_rs = $player_static_model->search( { 'player_data_currs.team_libl' => \'IS NOT NULL', }, { prefetch => [ 'player_data_currs', ], }, ); say scalar $roster_rs->all;
Like this:foreach my $player_static ($roster_rs->all){ say $player_static->player_data_currs; }
But this reports an error:LIBL::Schema::Result::PlayerDataCurr=HASH(0x39b40b8) LIBL::Schema::Result::PlayerDataCurr=HASH(0x39b2010) LIBL::Schema::Result::PlayerDataCurr=HASH(0x39b40e8)
Here's the error message:foreach my $player_static ($roster_rs->all){ say $player_static->player_data_currs->team_libl; }
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 +.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |