It works! Thanks very much!
I understand, now that you pointed it out (!), what I was doing wrong. The player_data_currs relationship is referring to a resultset because has_many relationships always refer to resultsets. So, although there is only a single record in $player_static->player_data_currs->all, I need to get the single object/record from the resultset and then call team_libl on it.
$player_static->player_data_currs->all->team_libl->id doesn't work either because, again, I am calling team_libl on a resultset not on a single object.
I see now that if I go the other way, from PlayerDataCurr to PlayerDataStatic through a belongs_to relation in PlayerDataCurr, I can accomplish what I'm after much more easily. I suppose this is because a belongs_to links to an object not a resultset. Is that right?
So, in PlayerDataCurr, I have this:And then this works:__PACKAGE__->belongs_to( "id_static", "LIBL::Schema::Result::PlayerDataStatic", { id => "id_static" }, { is_deferrable => 1, join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE", }, );
my $roster_rs = $player_curr_model->search( { team_libl => { '!=' => undef }, }, { prefetch => [ 'id_static', ], }, ); foreach my $player_curr ( $roster_rs->all ) { say $player_curr->team_libl; }
(I apparently have only a very fuzzy grasp of the difference in relationships. I have struggled over DBIx::Class::Relationship but never really understood it.)
Thanks again for your help. Your succinct explanation taught me something that I could not discover on my own.
In reply to Re^2: Trouble Getting Field Through A DBIx::Class::ResultSet Relation
by varanasi
in thread Trouble Getting Field Through A DBIx::Class::ResultSet Relation
by varanasi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |