On 10/1/06 10:44 AM, Randal L. Schwartz wrote:
> Is "now" a special value?  I thought I had to always give a DateTime
> object there?
> 
> And of course, you'll point out that this is documented in the most
> precise spot already, which is never the obvious spots. :)

You have to follow the trail of delegation to the source.  Ready? :)

Timestamp columns use the "timestamp" method maker in the
Rose::DB::Object::MakeMethods::Date class for the get_set method type (which
is the sole method type returned by the default_auto_method_types() method).

(Ack, there are lots of typos and bad links in the "methdod maps" for
date/time columns.  Fixing now...)

The docs for the "timestamp" method maker say:

http://search.cpan.org/~jsiracusa/Rose-DB-Object-0.753/lib/Rose/DB/Object/Ma
keMethods/Date.pm#timestamp

"When setting the attribute, the value is passed through the
parse_timestamp() method of the object's db attribute. If that fails, the
value is passed to Rose::DateTime::Util's parse_date() function. If that
fails, a fatal error will occur."

In some databases (e.g., Postgres), the string "now" is a valid timestamp
keyword:

http://search.cpan.org/dist/Rose-DB/lib/Rose/DB/Pg.pm#validate_timestamp_key
word

so it will be passed through the db's parse_timestamp() method as-is,
according to:

http://search.cpan.org/dist/Rose-DB/lib/Rose/DB.pm#parse_timestamp

"If STRING is a valid timestamp keyword (according to
validate_timestamp_keyword) [...] it is returned unmodified."

But even if that is not the case (e.g., for MySQL or some other database),
remember that the timestamp get_set method maker docs said, "If that fails,
the value is passed to Rose::DateTime::Util's parse_date() function."
Looking up the docs for that function:

http://search.cpan.org/~jsiracusa/Rose-DateTime-0.53/lib/Rose/DateTime/Util.
pm#parse_date

shows "now" as a valid value.

-John



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to