Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Update Primary Key with DBIx::Class (discard_changes)

by 1nickt (Abbot)
on Sep 19, 2019 at 09:54 UTC ( #11106371=note: print w/replies, xml ) Need Help??

in reply to Update Primary Key with DBIx::Class

Hi, your problem can be solved by using either of:

if($acct) { $acct->acctid( 'pv002' ); $acct->update; $acct->discard_changes; # add this }
... see the doc for discard_changes(), which has a somewhat counter-intuitive name but acts as a "commit" if you've made changes to your result object in your code.

Or else:

if($acct) { $acct->update({acctid => 'pv002'}); }
... which updates the record in the database immediately as well as in your program.

To find out what queries DBIx::Class is sending to your database, run your program with DBIC_TRACE=1 set in your environment.

Hope this helps!

Update: fixed missing clsoing brace, thanks pryrt

The way forward always starts with a minimal test.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11106371]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2019-10-19 03:12 GMT
Find Nodes?
    Voting Booth?