Permalink
Browse files

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

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
1 parent 7a99dc0 commit 504d16ccdfcd689eac31c1646957b06cc0ce55d1 @brownbeagle brownbeagle committed with lifo Feb 16, 2009
@@ -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

0 comments on commit 504d16c

Please sign in to comment.