To: | bugs-dbix-lazymethod [...] rt.cpan.org |
From: | Jonas B.Nielsen <jonasbn [...] io.dk> |
Subject: | Use of OID for Postgres is misleading |
Date: | Mon, 28 Jun 2004 13:16:54 +0200 |
Hi Casper,
I am currently working on a database implemented using Postgresql. In
order to find out how to get a autoincremented id out (serial in
Postgresql) I looked at your code, because I could remember you listed
this as a possible return value.
As far as I can tell you are using the OID for for this for DBD::Pg.
The OID is NOT the autoincremented value of a specified id, but a
internal reference number, it is unique but it is not the number which
should be returned in this case, hence it is not equal to the
autoincremented value.
Please see the definition of the OID here:
http://www.postgresql.org/docs/faqs/FAQ.html#4.16
It seems that DBI since 1.38 have specified a method called:
last_insert_id, this might be what we need?
From DBI POD:
--
Returns a value 'identifying' the row just inserted, if possible.
Typically this would be a value assigned by the database server to a
column with an auto_increment or serial type. Returns undef if the
driver does not support the method or can't determine the value.
--
Unfortunately it is driver specific and does not seem to be implemented
in DBD::Pg currently:
Please see: http://rt.cpan.org/NoAuth/Bug.html?id=3803
I do not know about DBD::MySQL
jonasbn