Add microsecond support for sqlite adapter [#1982 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
Alex Pooley 2009-02-16 11:44:48 +09:00 committed by Pratik Naik
parent 7a99dc0ac2
commit 504d16ccdf
2 changed files with 11 additions and 1 deletions

@ -150,6 +150,16 @@ def quote_column_name(name) #:nodoc:
%Q("#{name}")
end
# Quote date/time values for use in SQL input. Includes microseconds
# if the value is a Time responding to usec.
def quoted_date(value) #:nodoc:
if value.acts_like?(:time) && value.respond_to?(:usec)
"#{super}.#{sprintf("%06d", value.usec)}"
else
super
end
end
# DATABASE STATEMENTS ======================================

@ -456,7 +456,7 @@ def test_preserving_time_objects
)
# For adapters which support microsecond resolution.
if current_adapter?(:PostgreSQLAdapter)
if current_adapter?(:PostgreSQLAdapter) || current_adapter?(:SQLiteAdapter)
assert_equal 11, Topic.find(1).written_on.sec
assert_equal 223300, Topic.find(1).written_on.usec
assert_equal 9900, Topic.find(2).written_on.usec