[Dbix-class] Can't locate object method "source_name" via package

Brandon Black blblack at gmail.com
Fri Dec 8 23:42:02 GMT 2006


On 12/8/06, Tony <cshtreck at yahoo.com> wrote:
> I'm using
>
> DBIx::Class version 0.07003
> Catalyst version 5.7001
>
> The following command line program fails
>
> > cat ./t.pl
> #!/usr/local/bin/perl
>
> use lib '../lib';
> use My::Schema::TESTDB;
>
> The error is:
> "Can't locate object method "source_name" via package
> "My::Schema::TESTDB::Table1" at
> /usr/local/lib/perl5/site_perl/5.8.7/DBIx/Class/Schema.pm
> line 280.
> Compilation failed in require at ./t.pl line 4.
> BEGIN failed--compilation aborted at ./t.pl line 4.
>
> Okay, so I added a 'source_name' method ...
> gsipt# grep source_name
> ../lib/My/Schema/TESTDB/Table1.pm
> __PACKAGE__->source_name("table1");
>
> and it still fails.
>
> This code was working until I modified a different
> table in the db. After which I ran SchemaLoader to
> regenerate my Schema files and dumped them back into
> my TESTDB Schema directory ( lib/MY/Schema/TESTDB/ )
>
> I grep'ed my old lib/MY/Schema/TESTDB.old/ directory
> and there's no method there named 'source_name'
>

source_name is an accessor in all DBIx::Class::ResultSource-derived
objects, its not something you should be having to specify manually
for the tables.

You should try a "diff -urN" on the two directories (the old and new
TESTDB directories) to see everything that might have changed.
Another thing you might try is just "perl -c" on your table definition
pms like Table1.pm, as I suspect this error could result from a syntax
error in that file.

Either that or post up the source of Table1.pm might help.

-- Brandon



More information about the Dbix-class mailing list