Hi.

If this question has been asked and answered in the past, I apologize in
advance; my searches through the archives have been thus far unenlightening.

I'm finding that for Postgres relations that artificial primary keys
(but defined, for example, as "column_name INTEGER PRIMARY KEY DEFAULT
NEXTVAL('some_sequence')", as opposed to using the "SERIAL" type) give
me difficulty in Rose::DB::Object derivatives.

For a class created by the loader, I found that I needed to go in and
adjust the configuration by hand (this isn't a big deal as long as I
know it's a necessary step).  For example:
use DB::Object::AutoBase1;
our @ISA = qw(DB::Object::AutoBase1);

__PACKAGE__->meta->table('orders');

__PACKAGE__->meta->columns(
   orders_id             => { type => 'integer', not_null => 1,
sequence => 'orders_id_seq' },
   ...
);

__PACKAGE__->meta->primary_key_columns([ 'orders_id' ]);

# I added this sequence_names call.
__PACKAGE__->meta->primary_key()->sequence_names([ 'orders_id_seq' ]);

For generating new records in this table, the PK-can't-be-null problem
was catching me until I added that sequence_names call for the class
metadata.  Once that was added, Rose used the sequence appropriately for
generation of the PK values at insert time.

I guess I'm wondering why this step was necessary if the column metadata
itself already indicated that this particular column is associated with
a particular sequence.  Am I doing something wrong elsewhere?

Thanks.
- Ethan

--
Ethan Rowe
End Point Corporation
[EMAIL PROTECTED]




-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to