[Dbix-class] Should $rs->result_class end up on new results?

Peter Rabbitson rabbit+dbic at rabbit.us
Wed Jun 19 20:55:17 GMT 2013


On Wed, Jun 19, 2013 at 12:10:24PM -0700, Bill Moseley wrote:
> (sorry, sent this to -devel list first in error)
> 
> Quick question:
> 
> my $rs = $schema->resultset( 'Artist' );
> *$rs->result_class( 'DBIx::Class::ResultClass::HashRefInflator' );*
> print "Artist before " . $rs->result_class . "\n";
> $rs = $rs->search;
> print "Artist after " . $rs->result_class . "\n";
> 
> 
> Results in:
> 
> Artist before DBIx::Class::ResultClass::HashRefInflator
> Artist after MyApp::Schema::Result::Artist
> 
> 
> 
> http://search.cpan.org/~ribasushi/DBIx-Class-0.08250/lib/DBIx/Class/ResultClass/HashRefInflator.pmsays:
> 
> 
>    - Specify $rs->result_class on a specific resultset to affect only that
>    resultset (and any chained off of it); or
> 
> 
> I'm confused by that language.   Says "only that resultset" but also "and
> any chained off it".    Should the result_class be "sticky" and applied to
> new resultsets?
> 

This is in fact correct and by design. The docs do suck. The same issue 
blocks https://github.com/dbsrgits/dbix-class/pull/21 from being merged -
please read the enclosed comment and submit a patch documenting the 
*real* state of affairs. There is exhaustive testing codifying the 
actual behavior here (lines 20 through 55): 
https://github.com/dbsrgits/dbix-class/blob/master/t/inflate/hri.t#L20

Cheers



More information about the DBIx-Class mailing list