Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: DBIx::Class foreign key update woes

by castaway (Parson)
on Jul 18, 2006 at 20:52 UTC ( #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.


Comment on Re: DBIx::Class foreign key update woes
Select or Download Code
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
Node Status?
node history
Node Type: note [id://562125]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (10)
As of 2015-07-30 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls