[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:
> =

> "DBIx::Class::ResultSet::update(): Error executing 'UPDATE ...
> Duplicate entry '140949' for key 1 at =

> =

> How do we specify UPDATE ... blah WHERE (ID=3D'UNIQUE')
> =

>     my $result =3D [$c->model('WhateverDB::Whatever')->update({id =3D> $i=
> this=3D>that,
> another=3D>something,
>         });]
> =

> How to update with the unique column... or do I just have to delete the o=
> 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.


-------------- 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=

More information about the Catalyst mailing list