[Dbix-class] Issues with postgres timestamp in a primary key
Matt S Trout
dbix-class at trout.me.uk
Mon Jul 21 22:45:59 BST 2008
On Mon, Jul 21, 2008 at 03:58:26PM -0500, todd.e.rinaldo at jpmorgan.com wrote:
> Hi,
>
> Today, we ran across an issue with DBIC in postgres related to DBIx::Class::Storage::DBI::Pg. We needed to add a "timestamp with timezone" (which defaulted to "postgres now()") to an existing primary key in a table. The add went ok and the schema was updated in DBIx Class.
>
> When we attempted to add rows, where we explicitly specified the new timestamp field, all went well.
>
> When we attempted to create a row without specifying the timestamp primary key (since it defaulted), last_insert_id threw an error.
>
> From what we can tell as it currently stands, we cannot default primary keys to now() successfully. We are working around this by simply feeding in the current time when we call the insert, but would like to leverage a default on this primary key.
Hmm ... is the rest of the PK sufficiently unique? If it is, I'd just not
tell DBIC that the timestamp column is part of the PK.
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the DBIx-Class
mailing list