<div dir="ltr">Ok, I have an explanation.<div><br></div><div>We did a release and App::DB::ResultSet::UserRole is a new class. But, we cache User objects in Memcached (as a DBIC row).</div><div><br></div><div>And the old code did this:</div><div><br></div><div> $user->search_related( 'user_role', { ... } );</div><div><br></div><div>which then populated $user->{related_resultsets}{user_role} with the (default?) App::DB::Result class instance (and saved it in Memcached).</div><div><br></div><div>So, when we rolled out the new code it was using cached $user objects so $user->{related_resultsets}{user_role} was the base ResultSet object which didn't have the "my_method" method.</div><div><br></div><div>So, it may be as simple as delete $user->{related_resultsets} after fetching the $user object from cache. Can't be that expensive to look up the relationships.</div><div><br></div><div>Or we could be disruptive and blow away the cache at release time. But, it's not a problem that happens very often.</div><div><br></div><div><br></div><div>I wonder if it makes sense for DBIC to not save related_resultset in objects if there isn't a specific one -- which would have prevented this. Seems like quite an edge-case.</div><div><br></div><div><br></div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 15, 2015 at 4:45 PM, Bill Moseley <span dir="ltr"><<a href="mailto:moseley@hank.org" target="_blank">moseley@hank.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Wed, Jul 15, 2015 at 3:15 PM, Francisco Obispo <span dir="ltr"><<a href="mailto:francisco@obispo.link" target="_blank">francisco@obispo.link</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">The result of<br>
<br>
$self->related_resultset( 'user_role' )<br>
<br>
is a App::DB::ResultSet<br></blockquote><div><br></div></span><div>But it should return an App::DB::ResultSet::UserRole object. "my_method" is in the App::DB::ResultSet::UserRole class.</div><span class=""><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="color:rgb(80,0,80)">return $self->related_resultset( 'user_role' )->my_method->count > 0;</span></blockquote><div><br></div></span><div>When I printed Dumper $self->{related_resultsets} (in the related_resultset() method) when it was NOT working I was getting:</div><div><br></div><div><i>Note the class:</i></div><div><br></div><div><div> 'user_role' => bless( {</div><div> 'pager' => undef,</div><div> 'attrs' => {</div><div> 'is_depends_on' => 0,</div><div> 'cascade_copy' => 0,</div><div> 'accessor' => 'multi',</div><div> 'alias' => 'me',</div><div> 'bind' => 'ARRAY(0x7fdf9ac59198)',</div><div> 'join_type' => 'LEFT',</div><div> 'where' => 'HASH(0x7fdf9ac58fd0)',</div><div> 'cascade_delete' => 0</div><div> },</div><div> 'cond' => $VAR1->{'user_role'}{'attrs'}{'where'},</div><div> '_result_class' => 'App::DB::Result::UserRole',</div><div> 'result_source' => bless( {</div><div> '_columns' => 'HASH(0x7fdf85857f40)',</div><div> 'schema' => $VAR1->{'user_pref'}{'result_source'}{'schema'},</div><div> '_unique_constraints' => 'HASH(0x7fdf9696ffc8)',</div><div> '_relationships' => 'HASH(0x7fdf8585b0f8)',</div><div> 'result_class' => 'Appi::DB::Result::UserRole',</div><div> 'source_name' => 'UserRole',</div><div> 'resultset_class' => 'App::DB::ResultSet::UserRole',</div><div> '_columns_info_loaded' => 0,</div><div> 'resultset_attributes' => 'HASH(0x7fdf85857a48)',</div><div> '_primaries' => 'ARRAY(0x7fdf93dcb030)',</div><div> '_ordered_columns' => 'ARRAY(0x7fdf858417e8)',</div><div> 'name' => 'user_role'</div><div> }, 'DBIx::Class::ResultSource::Table' )</div><div> }, '<b>App::DB::ResultSet</b>' )</div></div><div> </div><div><br></div><div><br></div><div>And then when it is working correctly the Dump shows this:</div><div><br></div><div><div> 'user_role' => bless( {</div><div> 'result_source' => bless( {</div><div> 'source_name' => 'UserRole',</div><div> 'name' => 'user_role',</div><div> '_columns_info_loaded' => 0,</div><div> '_primaries' => 'ARRAY(0x4ceaea0)',</div><div> 'schema' => 'App::DB=HASH(0x2c458d0)',</div><div> 'result_class' => 'App::DB::Result::UserRole',</div><div> '_relationships' => 'HASH(0x783f628)',</div><div> 'resultset_attributes' => 'HASH(0x7834010)',</div><div> 'resultset_class' => 'App::DB::ResultSet::UserRole',</div><div> '_ordered_columns' => 'ARRAY(0x7825410)',</div><div> '_columns' => 'HASH(0x7837d20)',</div><div> '_unique_constraints' => 'HASH(0x4d17b40)'</div><div> }, 'DBIx::Class::ResultSource::Table' ),</div><div> 'attrs' => {</div><div> 'bind' => 'ARRAY(0x7b1ace0)',</div><div> 'cascade_delete' => 0,</div><div> 'accessor' => 'multi',</div><div> 'cascade_copy' => 0,</div><div> 'is_depends_on' => 0,</div><div> 'alias' => 'me',</div><div> 'where' => 'HASH(0x7b71fe0)',</div><div> 'join_type' => 'LEFT'</div><div> },</div><div> 'pager' => undef,</div><div> '_result_class' => 'App::DB::Result::UserRole',</div><div> 'cond' => $VAR1->{'user_role'}{'attrs'}{'where'}</div><div> }, '<b>App::DB::ResultSet::UserRole</b>' )</div><div> };</div></div></div><span class=""><font color="#888888"><div><br></div>-- <br><div>Bill Moseley<br><a href="mailto:moseley@hank.org" target="_blank">moseley@hank.org</a></div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Bill Moseley<br><a href="mailto:moseley@hank.org" target="_blank">moseley@hank.org</a></div>
</div></div></div>