Title: Loader make_modules problem?
I have to start by saying that I really like the make_modules concept; I dreaded having to hand-edit multiple files for large changes in database schema, but having module code to customize is necessary for many apps; this approach is the best of both worlds.
That said, I have the following schema:
DROP TABLE public.dogs;
DROP TABLE public.contacts;
CREATE TABLE public.contacts (
id SERIAL NOT NULL
, first_name VARCHAR(30)
, last_name VARCHAR(30)
, middle VARCHAR(30)
, title VARCHAR(10)
, phone VARCHAR(20)
, phone_2 VARCHAR(20)
, address_line_1 VARCHAR(255)
, address_line_2 VARCHAR(255)
, city VARCHAR(30)
, state VARCHAR(30)
, zip VARCHAR(10)
, country VARCHAR(30) DEFAULT 'United States'
, email VARCHAR(255)
, url VARCHAR(255)
);
COMMENT ON COLUMN public.contacts.title IS 'Like Dr., Mrs., etc.';
CREATE TABLE public.dogs (
id SERIAL NOT NULL
, fullname TEXT
, owner INTEGER
, birthdate DATE
);
COMMENT ON TABLE public.dogs IS 'Information associated with a single dog';
ALTER TABLE public.contacts
ADD CONSTRAINT PK_CONTACTS
PRIMARY KEY (id);
ALTER TABLE public.dogs
ADD CONSTRAINT PK_DOGS
PRIMARY KEY (id);
ALTER TABLE public.dogs
ADD CONSTRAINT fk_dogs_1
FOREIGN KEY (owner)
REFERENCES public.contacts (id)
ON DELETE RESTRICT
ON UPDATE CASCADE;
And a simple loader script:
#!/usr/bin/perl
use strict;
use warnings;
use lib '../lib';
use Rose::DB::Object::Loader;
use Dog::DB;
my $loader =
Rose::DB::Object::Loader->new(
db => Dog::DB->new(),
class_prefix => 'Dog::DB'
);
$loader->make_modules(
#assumes this file is in project/scripts directory and that
#there is a project/lib folder
module_dir => '../lib'
);
The resulting modules contain references to some modules that do not exist, it seems. For example, the Dog::DB::Dog module looks like:
package Dog::DB::Dog;
use strict;
use Dog::DB::DB::Object::Base1;
our @ISA = qw(Dog::DB::DB::Object::Base1);
__PACKAGE__->meta->table('dogs');
__PACKAGE__->meta->columns(
id => { type => 'serial', not_null => 1 },
fullname => { type => 'text' },
owner => { type => 'integer' },
birthdate => { type => 'date' },
);
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
__PACKAGE__->meta->foreign_keys(
contact => {
class => 'Dog::DB::Contact',
key_columns => {
owner => 'id',
},
},
);
__PACKAGE__->meta->initialize;
1;
And Dog::DB::DB::Object::Base1 isn’t actually created and shouldn’t be, I suppose? In any case, using code based on the generated modules gives an error:
Can't locate Dog/DB/DB/Object/Base1.pm in @INC (@INC contains: ../lib /sw/lib/perl5 /sw/lib/perl5/darwin /Library/Perl/5.8.1/darwin-thread-multi-2level /Users/sdavis/MyMods /Users/sdavis/perl/MyModules /Users/sdavis/perl/bioperl/ensembl/modules /Users/sdavis/perl/bioperl/ensembl-compara/modules /Users/sdavis/perl/bioperl/TFBS /Users/sdavis/Library/R/library/RSPerl/share/lib/perl5/site_perl/5.8.6/darwin-thread-multi-2level /Users/sdavis/Library/R/library/RSPerl/share/lib/perl5/site_perl/5.8.6 /Users/sdavis/Library/R/library/RSPerl/share/lib/perl5/site_perl /System/Library/Perl/5.8.6/darwin-thread-multi-2level /System/Library/Perl/5.8.6 /Library/Perl/5.8.6/darwin-thread-multi-2level /Library/Perl/5.8.6 /Library/Perl /Network/Library/Perl/5.8.6/darwin-thread-multi-2level /Network/Library/Perl/5.8.6 /Network/Library/Perl /System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level /System/Library/Perl/Extras/5.8.6 /Library/Perl/5.8.1 .) at ../lib/Dog/DB/Dog.pm line 5.
BEGIN failed--compilation aborted at ../lib/Dog/DB/Dog.pm line 5.
Compilation failed in require at ../lib/Dog/DB/Dog/Manager.pm line 3.
BEGIN failed--compilation aborted at ../lib/Dog/DB/Dog/Manager.pm line 3.
Any thoughts? Did I miss a step somewhere?
Thanks,
Sean
- [RDBO] Loader make_modules problem? Sean Davis
- Re: [RDBO] Loader make_modules problem? Sean Davis
- Re: [RDBO] Loader make_modules problem? John Siracusa
- Re: [RDBO] Loader make_modules problem? Sean Davis
