[Dbix-class] source_name immutable in latest dev release

Matt S Trout dbix-class at trout.me.uk
Tue Jun 5 00:53:26 GMT 2007


On Fri, Jun 01, 2007 at 01:13:35PM +0200, Tobias Kremer wrote:
> After installing the latest dev release 0.07999_02 I can't modify the
> source_name attribute anymore ("cannot alter the value of 'source_name'
> on objects of class 'DBIx::Class::ResultSource'"). This breaks the
> result_source_instance trick to inject arbitrary SQL. Is this intended
> and if yes, how can I work around this?
> 
> Here's what I'm doing:
> 
> ----
> 
> my $source = MyApp::Schema::User->result_source_instance();
> my $my_source = $source->new( $source );
> 
> @MyApp::Schema::UserView::ISA = ('MyApp::Schema::User');
> $source_new->result_class( 'MyApp::Schema::UserView' );
> 
> $my_source->source_name( 'UserCustomSQL' );    # BOOM!
> $my_source->name( \"($sql)" );
> 
> MyApp::Schema->register_source( 'MyApp::Schema::UserCustom' => $my_source );
> 
> ----
> 
> For now, I just removed the ->source_name( ... ) line and everything seems
> to work just like before. Is this safe? Thanks!

No, very very not safe.

Try ->new({ %$source, source_name => 'UserCustomSQL' }) for a workaround and
we'll aim for a proper fix for 05

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/             http://www.shadowcatsystems.co.uk/ 



More information about the Dbix-class mailing list