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

Ben Tilly btilly at gmail.com
Thu Sep 22 18:38:39 GMT 2011


On Thu, Sep 22, 2011 at 11:10 AM, Lyle Kopnicky <lwk at rentrakmail.com> wrote:
> On Thu, Sep 22, 2011 at 2:44 AM, Roman
> Daniel <roman.daniel at davosro.cz> wrote:
>>
>> 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.
>
> Ah, of course. That was one of those things that occurred to me, but I
> didn't pursue it, because it seems I can't put any code above the
> __PACKAGE__->table call, because DBIx::Class::Schema::Loader will be broken:
> # Created by DBIx::Class::Schema::Loader
> # DO NOT MODIFY THE FIRST PART OF THIS FILE
> ...
> __PACKAGE__->table("my_table");
> ...
> # Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-08-10 17:33:49
> # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yDSIDkS8OrqYpQJRIWPhkA
> __PACKAGE__->table_class('My::Schema::ResultSource::MyTable');
> # You can replace this text with custom code or comments, and it will be
> preserved on regeneration

The development version of DBIx::Class::Schema::Loader allows you to
modify everything in the autogenerated part at generation time.  You
can get it from
http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits/DBIx-Class-Schema-Loader.git;a=summary.

An example use case is to save the text to a file, run perltidy on it,
then slurp up the file.  But you can also add methods, rearrange
things, etc.

Alternately you can have a make rule that is used to rebuild your
stuff.  It can call DBIx::Class::Schema::Loader and can then run
through and modify everything you need modified.

It is also worth a look through DBIx::Class::Schema::Loader::Base -
even if nothing there can solve this problem, it is nice to know what
your options are.

> --
> 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