On 8/4/07, Ricardo SIGNES <[EMAIL PROTECTED]> wrote:
> I can't find this documented, and it seems like a very imporant default to
> document, given the obnoxious way in which the database-level defaults for
> datetimes and the like can differ.

The first thing to understand is that the default can be any value
that the column can take.  Second, you have to look up the column
type's "method map" and follow that to the method maker docs.  For
example, for a "datetime" column type, follow the trail of docs:

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata.pm#column_type_classes

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Column/Datetime.pm#METHOD_MAP

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/MakeMethods/Date.pm#datetime

"When setting the attribute, the value is passed through the
parse_TYPE() method of the object's db attribute, where TYPE is the
value of the type option. If that fails, the value is passed to
Rose::DateTime::Util's parse_date() function."

http://search.cpan.org/dist/Rose-DateTime/lib/Rose/DateTime/Util.pm#parse_date

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

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

The "keywords" vary among dbs:

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

It's a long road, but that's the price of flexibility I guess.

Anyway, the short answer (too late?) is that "now()" is passed as-is
(i.e., unquoted, inlined) to MySQL, "current" is passed as-is to
Informix (and "current datetime year to blah blah" etc.), "now" is
passed as-is to Postgres, and "now" and "today" and other things are
parsed by Rose::DateTime::Util::parse_date() if none of the other
rules apply.

To find all this, you basically end up looking at the method-maker
docs, then in the Rose::DB::* docs for validate_*_keyword() to see
what strings are passed through, then in the
Rose::DateTime::Util::parse_date() docs to see the last resort.

-John

-------------------------------------------------------------------------
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
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to