Just to expand the example, resetting class->result_source_instance to use the source from the new schema instead of the original schema appears to fix the problem:
> use Handel::Cart::Schema;
>
> my $schema = Handel::Cart::Schema->connect($ENV{HandelDBIDSN});
> my $new = $schema->compose_namespace('Foo');
>
> print $schema->class('Items'), "\n";
> print $new->class('Items'), "\n";
>
> print $schema->class('Items')->result_source_instance, "\n";
> print $new->class('Items')->result_source_instance, "\n";
>
> print $schema->source('Items'), "\n";
> print $new->source('Items'), "\n";
>
>
> # this ishacky, but it appears to work...
> $new->class('Items')->result_source_instance($new->source('Items'));
> $new->source('Items')->add_column('custom' => {accessor => 'foo'});
> $new->class('Items')->register_column('custom' => {accessor => 'foo'});
>
> print $new->class('Items')->columns, "\n";
> print $schema->class('Items')->columns, "\n";
> print $new->class('Items')->columns, "\n";
> print $schema->class('Items')->columns, "\n";
>
> $new->resultset('Items')->delete_all;
> $new->resultset('Items')->create({id=>1, custom=>'foo'});
> print $new->resultset('Items')->find(1)->bar;
At this point, everything prints the right amount of columns, and the
accessor is created in the correct source class.
One more item of interest...if I try this instead:
> # this ishacky, but it appears to work...
> $new->class('Items')->result_source_instance($new->source('Items'));
> $new->source('Items')->add_column('custom' => {accessor => 'foo'});
> $new->class('Items')->register_column('custom' =>
> $new->source('Items')->column_info('custom'));
I get this:
> Attempt to free unreferenced scalar: SV 0x250793c at
> F:\CatInABox\extlib/SQL/Abstract/Limit.pm line 325.
> Attempt to free unreferenced scalar: SV 0x25124bc at
> F:\CatInABox\extlib/SQL/Abstract/Limit.pm line 325.
So, at this point, I think I can work around the nuances. I'm just not
sure if anything in there related to result_source_instance after
compose_namespace is a bug or a feature.
-=Chris
signature.asc
Description: OpenPGP digital signature
_______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ Searchable Archive: http://www.mail-archive.com/[email protected]/
