OK,
Here's the table that Class::DBI::Loader seems to be choking on:

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' );
and here we see I interrogate PostgreSQL to see if the table got defined the way I expected it to:
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 far so good.

So then I write a very simple piece of code that utilizes Class::DBI::Loader to get to my database.

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 } );
Nothing fancy here...yet... just want to see if I can connect and have the loader do its thing.

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?


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

In reply to Class::DBI::Loader can't find a primary key... by blue_cowdawg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.