[Dbix-class] inflate_results and source_name

Matt S Trout mst at shadowcat.co.uk
Thu May 6 20:17:38 GMT 2010


On Sun, May 02, 2010 at 08:21:11PM -0700, Bill Moseley wrote:
> On Thu, Apr 29, 2010 at 2:08 PM, Matt S Trout <mst at shadowcat.co.uk> wrote:
> 
> > source_name is a proxy through to the result_source_instance in class data.
> >
> > If you don't call
> >
> > __PACKAGE__->table(__PACKAGE__->table);
> >
> > in a subclass to get a new source, you don't have a new source.
> >
> > So you've just set it four times on the same thing and the last one will
> > win.
> >
> 
> Hum, Ok.  You mean this?
> 
> $ cat Track1.pm
> package MyApp::Result::Track1;
> use parent MyApp::Result::Track;
> __PACKAGE__->table(__PACKAGE__->table);
> 1;
> 
> (same for Track2 and Track3)
> 
> position 3, ref=MyApp::Result::Track3 source_name=Track
> position 2, ref=MyApp::Result::Track2 source_name=Track
> position 1, ref=MyApp::Result::Track1 source_name=Track
> 
> How should the subclasses be set up so that I get this back instead:
> 
> position 3, ref=MyApp::Result::Track3 source_name=Track3
> position 2, ref=MyApp::Result::Track2 source_name=Track2
> position 1, ref=MyApp::Result::Track1 source_name=Track1

Er.

You've changed the class with rebless() but not touched the $obj->result_source.

You need to set that to $schema->source($new_class).

-- 
Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a clue

http://shadowcat.co.uk/blog/matt-s-trout/   http://twitter.com/shadowcat_mst/

Email me now on mst (at) shadowcat.co.uk and let's chat about how our Catalyst
commercial support, training and consultancy packages could help your team.



More information about the DBIx-Class mailing list