John Siracusa writes:
> On 10/10/07, George Hartzell <[EMAIL PROTECTED]> wrote:
> > - As written, it almost works. I'm clearly running around behind
> > the back of RDBO's copy of that row's values, $new_num->counter is
> > still zero even though the row has been updated. What's the
> > cleanest way to fix this?
>
> Is there really anything to fix? The in-memory and in-db states will
> never be guaranteed to match under any circumstances, including this
> one :)
Well, if I want to return a copy of the object, complete with the new
value for the counter, I've taken to:
my $id = $new_num->id();
$new_num = undef;
$new_num = RoR::DB::SampleSheetNumber->new(id => $id);
$new_num->load();
It occurs to me that there might be a $new_num->reload(), or that
$new_num->load on an already loaded object might be guaranteed to not
do something silly, or....
> [...]
> > - Can anyone shed any light on the Scalar::Defer trick that John
> > mentions? In particular, when would that code run?
>
> It'll run when the default value for that column is requested and the
> column value is undef. (There will eventually be an option to get the
> default only when the column value has never been set.) To get a feel
> for when it runs, set the default value to something like this:
>
> default => defer { print "Getting default\n"; 123 }
Thanks!
g.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object