Re: primary key error with PostgreSQL
[prev]
[thread]
[next]
[Date index for 2005/05/22]
On 5/20/05, Sam Kelly <samuel.kelly@xxxxx.xxx> wrote:
> I dropped the table (no foreign keys) and recreated it with this:
>=20
> meal=3D> CREATE TABLE item (
> meal(> itemid SERIAL PRIMARY KEY,
> meal(> description TEXT,
> meal(> qty INTEGER
> meal(> );
> NOTICE: CREATE TABLE will create implicit sequence "item_itemid_seq"
> for "serial" column "item.itemid"
> NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
> "item_pkey" for table "item"
> CREATE TABLE
> meal=3D> \q
>=20
> I still get the exact same error message :-(. I notice the SQL in the
> error message includes itemid in the field list for the INSERT. Does
> Class::DBI actually ask the database what the primary key is or does
> it just use the first element in the fields list? Either way it should
> work, right?
Are you telling Class::DBI about the new sequence?
__PACKAGE__->sequence('item_itemid_seq');
If you want this stuff to be configured automatically then you can use
the Class::DBI::Pg module to automatically configure the table for you
with the set_up_table method.
__PACKAGE__->set_up_table('item');
Cheers,
Cees