http://www.perlmonks.org?node_id=1015929

blue_cowdawg has asked for the wisdom of the Perl Monks concerning the following question:

OK.. so I have this Class::DBIx schema that I've assembled using dbicdump and one of the tables I dumped is called "planet" in the database itself.

If I look in the result set directory I find all the tables represented there including planet.

use MooseX::MarkAsMethods autoclean => 1; extends 'DBIx::Class::Core'; __PACKAGE__->load_components("Schema::Versioned"); __PACKAGE__->table("planet"); __PACKAGE__->add_columns( "planet_id", { data_type => "integer", extra => { unsigned => 1 }, is_auto_increment => 1, is_nullable => 0, }, "starport", { data_type => "integer", default_value => 1, is_nullable => 0 }, "diameter", { data_type => "integer", default_value => 0, is_nullable => 0 }, "atmosphere", { data_type => "integer", default_value => 0, is_nullable => 0 }, "population", { data_type => "integer", default_value => 0, is_nullable => 0 }, "government", { data_type => "integer", default_value => 0, is_nullable => 0 }, "lawlevel", { data_type => "integer", default_value => 0, is_nullable => 0 }, "starorbit", { data_type => "integer", extra => { unsigned => 1 }, is_foreign_key => 1, is_nullable => 0, }, ); __PACKAGE__->belongs_to( "starorbit", "RPG::Traveller::DBIx::Starmap::Schema::Result::Starorbit", { starorbit_id => "starorbit" }, { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRIC +T" }, ); __PACKAGE__->set_primary_key("planet_id"); __PACKAGE__->meta->make_immutable;
(I excised out the embedded POD)

So.. why when I run a test against this (or write code against it it can't be found in the schema?

For those curious here's my test (very simple):

use Test::More tests => 1; { use RPG::Traveller::DBIx::Schema; my $db = RPG::Traveller::DBIx::Schema->connect( 'dbi:mysql:hostname=localhost:database=starmapper', 'starmapper', 'secretsquirrel' ); # not the real creds above... $db->resultset('Planet'); }

Test bombs with:

t/10-planet.t ............. Can't find source for Planet at /usr/lib/p +erl5/site_perl/5.14/DBIx/Class/Schema.pm line 1101. DBIx::Class::Schema::throw_exception('RPG::Traveller::DBIx::Sc +hema=HASH(0x2006c030)', 'Can\'t find source for Planet') called at /u +sr/lib/perl5/site_perl/5.14/DBIx/Class/Schema.pm line 599 DBIx::Class::Schema::source('RPG::Traveller::DBIx::Schema=HASH +(0x2006c030)', 'Planet') called at /usr/lib/perl5/site_perl/5.14/DBIx +/Class/Schema.pm line 550 DBIx::Class::Schema::resultset('RPG::Traveller::DBIx::Schema=H +ASH(0x2006c030)', 'Planet') called at t/10-planet.t line 8


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg