[Dbix-class] table referencing itself
Daniel McBrearty
danielmcbrearty at gmail.com
Wed Dec 20 20:09:56 GMT 2006
I have a table that looks like this:
CREATE TABLE whatever (
id SERIAL PRIMARY KEY,
whatever_id INTEGER NOT NULL REFERENCES whatever(id),
.
.
.
);
Now when I populate the table for the very first time, the first row
will reference itself. Some other rows will ref themselves, some will
ref other rows.
My question : when I do
my $w = $schema->resultset('Whatever')->create( ... )
I need to basically say
{whatever_id => this.id,
.... }
but of course it isn't "this" ....
Is there a way to get the id of the object being created in the
statement doing the creation? I don't even know if the db (postgresql)
can do that ... ?
The alternative is to make whatever_id not required, and post-fill it,
but I prefer not as it should always have a value.
Anyone know?
thanks
Daniel
--
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131
More information about the Dbix-class
mailing list