[Dbix-class] DBIX, row update problem

Bob MacCallum uncoolbob at gmail.com
Thu Oct 4 10:28:46 GMT 2012


I'm not a DBIC guru but the "SET item = ?" concerns me.  It looks like
your or DBIC is trying to do too much at the same time (item's value
shouldn't change).
Wouldn't it be better to find (or find_or_create)  the row object
first and update it in a second call?


On Thu, Oct 4, 2012 at 1:22 AM, Rajeev Prasad <rp.neuli at yahoo.com> wrote:
>
> I am only intending to update a column in a row based on 'item' value. Item
> value is unique constraint column.
>
> DBIx code:
>
>     $schema->resultset('Itemlist')->update(
>     {
>         item => $item,
>         item_comment => $mycomments
>     },
>     {key =>'item'}    #uniq constraint on item
>     );
>
> when i look in table row it is updated!!! but i get this err in apache log
> and throws a 500 http error. (pl script dies)
>
> generates this error in apache log:
>
> table name itemlist
>
>  DBIx::Class::ResultSet::update(): DBI Exception: DBD::mysql::st execute
> failed: Duplicate entry 'item1' for key 'item' [for Statement "UPDATE
> itemlist SET item = ?, item_comment = ?" with ParamValues: 0='bigitem',
> 1='test comment'] at xxxyyy.pl line 60, referer: http://xxxyyyzzz....
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk



More information about the DBIx-Class mailing list