blue_cowdawg has asked for the wisdom of the Perl Monks concerning the following question:
OK,
Here's the table that Class::DBI::Loader seems to
be choking on:
and here we see I interrogate PostgreSQL to see if the table got defined the way I expected it to:create table account ( user_id SERIAL not null primary key, username varchar(15) not null, passwd varchar(15) not null, person_id integer not null references person(person_id) on delete cascade, active bool not null default 'true', locked bool not null default 'false' );
So far so good.peter_trialdb=> \d account Table "public.account" Column | Type | Modifie +rs ------------+-----------------------+--------------------------------- +----------------------------- account_id | integer | not null default nextval('accoun +t_account_id_seq'::regclass) username | character varying(15) | not null passwd | character varying(15) | not null person_id | integer | not null active | boolean | not null default true locked | boolean | not null default false Indexes: "account_pkey" PRIMARY KEY, btree (account_id) Foreign-key constraints: "account_person_id_fkey" FOREIGN KEY (person_id) REFERENCES person +(person_id) ON DELETE CASCADE
So then I write a very simple piece of code that utilizes Class::DBI::Loader to get to my database.
Nothing fancy here...yet... just want to see if I can connect and have the loader do its thing.use strict; use Class::DBI::Loader; use Data::Dumper; my $loader = Class::DBI::Loader->new( dsn=>'dbi:Pg:dbname=peter_trialdb', user=>'peter', password=>'$3cr3t$qu!rr3l', namespace=>'Db', relationships=>1, options=>{ AutoCommit=>1 } );
I run this using a Perl version 5.8.5 interpreter against Class::DBI::Loader version 0.32 and I get the following insane error:
./automation.pl Use of uninitialized value in split at /usr/lib/perl5/site_perl/5.8.5/ +Class/DBI/Pg.pm line 26. public.account has no primary key at /usr/lib/perl5/site_perl/5.8.5/Cl +ass/DBI/Loader/Generic.pm line 164
NOW! the plot thickens. I run the same code against my test machine at home and I get no errors. WTF? The module's version is the same and the Perl interpreter is of the same version. The schemas between the test database and my "production" environment are the same since I use the same SQL script to create them.
Anybody out there have any insight to this oddity of nature?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Class::DBI::Loader can't find a primary key...
by Joost (Canon) on Sep 27, 2006 at 19:07 UTC | |
by blue_cowdawg (Monsignor) on Sep 27, 2006 at 20:11 UTC |