[Catalyst] update record with unique ID
Christopher H. Laco
claco at chrislaco.com
Mon Apr 9 20:50:44 GMT 2007
Michael Higgins wrote:
> Hello, Cat-list-ers,
> =
> Here's a pared-down version of my question, hoping it's an easy one:
> =
> ERROR:
> "DBIx::Class::ResultSet::update(): Error executing 'UPDATE ...
> Duplicate entry '140949' for key 1 at =
> =
> QUESTION:
> How do we specify UPDATE ... blah WHERE (ID=3D'UNIQUE')
> =
> CODE:
> my $result =3D [$c->model('WhateverDB::Whatever')->update({id =3D> $i=
d},{
> this=3D>that,
> another=3D>something,
> });]
> =
> How to update with the unique column... or do I just have to delete the o=
ld
> record and insert a new one from scratch?
> =
> TIA,
> =
Does not compute.
First, I'm going to assume id is your primary key. Why would you want to
change that?
Second, based on the error you've provided you already have another
record with the same $id you're trying to update this record to...
Aside from that, conceptually, you want to find, then alter something...
->find($oldid)->update({id =3D> $newid});
Whether the db/dbix will alow you to move the primary key like that, I
can't say. I generally try to avoid evil magic.
-=3DChris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070409/1105=
21c9/signature.pgp
More information about the Catalyst
mailing list