[Dbix-class] DBIx:.Class::Candy + DBIx::Class::DynamicSubclass ?

Marco Vittorini Orgeas marco at vittorini.org
Sat Aug 27 15:35:50 GMT 2016


Hi,
I'm trying to combine Candy with the functionality of 
DBIx::Class::DynamicSubclass and it seems the Candy's export/import 
"magic" get in the way of DynamicSubclass, so something like that:

> use utf8;
> package App::Schema::Result::User;
>
> use Moose;
> use MooseX::NonMoose;
> use MooseX::MarkAsMethods autoclean => 1;
> use DBIx::Class::Candy -autotable => v1,
> 	-components => ['InflateColumn::DateTime',
> 					'TimeStamp',
> 					'InflateColumn::ClassTypeEnum',
> 					'DynamicSubclass',
> 				];
> 					
> =head1 COMPONENTS LOADED
>
> =over 4
>
> =item * L<DBIx::Class::InflateColumn::DateTime>
>
> =item * L<DBIx::Class::TimeStamp>
>
> =item * L<DBIx::Class::InflateColumn::ClassTypeEnum>
>
> =back
>
> =head1 TYPECAST MAP
>
> =head2 Map of users type for single-table inheritance
>
> 	Doctor => App::Schema::Result::Doctor
> 	Assistant => App::Schema::Result::Assistant
>
> =cut
>
> __PACKAGE__->typecast_map(type => {
>         'Doctor' => 'App::Schema::Result::Doctor',
>         'Assistant' => 'App::Schema::Result::Assistant',
> });

Dies with:
> Couldn't instantiate component "App::Model::DB", "{UNKNOWN}: Can't locate object method "result_source_instance" via package "App::Schema::Result::User" at (eval 634) line 18.
> Compilation failed in require at /home/marco/.perlbrew/libs/perl-5.22.1/lib/perl5/Class/C3/Componentised.pm line 150. at /home/marco/.perlbrew/libs/perl-5.22.1/lib/perl5/Class/C3/Componentised.pm line 155
> Compilation failed in require at /home/marco/.perlbrew/libs/perl-5.22.1/lib/perl5/Catalyst/Test.pm line 155.
> BEGIN failed--compilation aborted at t/01app.t line 6.
> t/01app.t .............. Dubious, test returned 255 (wstat 65280, 0xff00)
> No subtests run

because this line:
> my $real_columns = $this->result_source_instance->_columns;
(https://metacpan.org/source/SYBER/DBIx-Class-DynamicSubclass-0.03/lib/DBIx/Class/DynamicSubclass.pm#L159)
expects to find a "result_source_instance" method which candy seems to 
have cleaned up.

Do I have any alternatives to get that method at run-time with Candy, or 
should I give up and don't use the Candy module?

Thank you.

Marco



More information about the DBIx-Class mailing list