[Dbix-class] Re: Get table name from ResultSet class?

Roman Daniel roman.daniel at davosro.cz
Thu Sep 22 09:44:27 GMT 2011


It is not clear from your code sample,
but your __PACKAGE__->table_class call has to occur before
__PACKAGE__->table call, otherwise it has no effect.

Roman


2011/9/22 Lyle Kopnicky <lwk at rentrak.com>:
> On Wed, Sep 14, 2011 at 11:28 AM, Alexander Hartmaier
> <alexander.hartmaier at t-systems.at> wrote:
>>
>> Because the method foo is a method of the result (row) class and not the
>> resultsource class.
>> If you want to add resultsource methods you need to write a
>> ResultSource::Table (or ::View) subclass and assign it to your result class:
>> __PACKAGE__->table_class('Your::Model::ResultSource::WithFooMethod');
>
> Thanks, but this does not seem to work. I set the table_class on the Result
> class as you said, but then when I get the ResultSource class, it doesn't
> have the methods I defined:
> package My::Schema::ResultSource::MyTable;
> use Moose;
> extends 'DBIx::Class::ResultSource::Table';
> sub foo { ... }
> 1;
> package My::Schema::Result::MyTable;
> ...
> __PACKAGE->table_class('My::Schema::ResultSource::MyTable');
> 1;
> my $schema = My::Schema->connect(...);
> my $source = $schema->source('MyTable');
> $source->foo(...);
> Blows up because foo is not found. In fact, the $source object is of class
> My::Schema::ResultSource::Table, not my custom class.
>
> --
> Lyle Kopnicky | Software Developer
> 503.284.7581 x260 | lwk at rentrak.com
> RENTRAK | www.rentrak.com | NASDAQ: RENT
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>



More information about the DBIx-Class mailing list