Re: Filtering Active Records by date

Matthew Rudy
Tue, 18 Sep 2007 14:12:23 -0000

Arthur Lyman wrote:
> I am filtering records by date with the find method and with the newer
> API mentioned above, but I do not convert the date to a string with
> the ''to_s'' method.  I believe that Active Record with the
''find''
> method does this for you.  If, on the other hand,  you were to use
> ''find_by_sql'', you would need to format the date as a
string with
> single quotes and in a format that your particular database can
> recognize and evaluate correctly.  For that reason, the
''find_by_sql''
> method seems less portable to another database whose date string
> formats may not completely overlap with anothers'' formats.
>
> On Sep 18, 8:41 am, Rob Biedenharn
<R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org>

yeah.
this comes through "sanitize_sql_array", which uses
"connection.quote",
which calls "quote_date" "if value.acts_like?(:date) ||
value.acts_like?(:time)"
where "quote_date" just calls "to_s(:db)" on it.

--
Posted via http://www.ruby-forum.com/.