Skip to content

Commit

Permalink
Add microsecond support for sqlite adapter [#1982 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information
brownbeagle authored and lifo committed Apr 21, 2009
1 parent 7a99dc0 commit 504d16c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -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 ======================================

Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/base_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit 504d16c

Please sign in to comment.