http://www.perlmonks.org?node_id=562125


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