You should also be able to do:
$o->save(changes_only => 1);
for a similar effect.
What's happening is that when you load(), you get the current value of
the timestamp column, and when you save(), the current value is saved
right back into the column. Apparently MySQL's "on update
CURRENT_TIMESTAMP" directive doesn't make it override an explicitly
provided value.
Anyway, a solution that lets you use plain old save() as well as
save(changes_only => 1) is to set an on_save trigger on the timestamp
column to set its value to undef prior to save()ing.
http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Column.pm#TRIGGERS
columns =>
[
...
date_updated => { type => 'timestamp', on_save => sub {
shift->date_updated(undef) } },
...
If that's a common occurrence in your code, you could make and
register your own custom column class that incorporates this trigger
by default, or override add_columns() or some other method in your
custom Metadata subclass to apply this trigger to all columns named
"date_updated," or whatever your convention might be, etc.
-John
Depending on the database, some values are passed through as-is to be
evaluated server-side. In your case (MySQL) the value "now()" is
passed through as-is and evaluated by the database server, but the
value "now" is evaluated client-side and the resulting date is passed
to the server.
The things evaluated client-side are called "keywords" in Rose::DB
parlance. Such keywords are defined in Rose::DB and its
database-specific subclasses. Example:
http://search.cpan.org/dist/Rose-DB/lib/Rose/DB/MySQL.pm#validate_timestamp_keyword
Values that are evaluated server-side must be re-load()ed if you want
to know what value the database actually ended up choosing.
-John