Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: DBIx::Class foreign key update woes

by castaway (Parson)
on Jul 18, 2006 at 20:52 UTC ( [id://562125]=note: print w/replies, xml ) Need Help??


in reply to DBIx::Class foreign key update woes

Hi Phil,
If you turn on SQL debugging (set DBIX_CLASS_STORAGE_DBI_DEBUG to true in your environment), you'll notice that the status object gets fetched when you first try to access ->descr, and isn't refetched when you just change a column entry in the check object. It would indeed be nice if that magically updated a related object, and I'll propose it.

In the meantime you can do either:

my $newstatus = $schema->resultset('Status')->find(2); $check->status($newstatus);
or:
$check->update({status => 2}); $check->discard_changes();
It's not as pretty.. but it works.

C.

Replies are listed 'Best First'.
Re^2: DBIx::Class foreign key update woes
by philcrow (Priest) on Jul 18, 2006 at 21:07 UTC
    Thanks for the advice. It worked in my test.

    As for:

    It would indeed be nice if that magically updated a related object
    I don't need it to update that other object, just discard what it's holding so additional accesses will refetch it.

    Phil

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2024-04-19 00:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found