File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
lib/active_record/connection_adapters/sqlserver/type Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -14,15 +14,15 @@ def apply_seconds_precision(value)
1414
1515 def seconds_precision ( value )
1616 return 0 if fractional_scale == 0
17- seconds = value . send ( fractional_property ) . to_f / fractional_operator . to_f
18- seconds = ( ( seconds * ( 1 / fractional_precision ) ) . round / ( 1 / fractional_precision ) ) . round ( fractional_scale )
17+ seconds = value . send ( fractional_property ) . to_d / fractional_operator . to_d
18+ seconds = ( ( seconds * ( 1 / fractional_precision ) ) . round / ( 1 / fractional_precision ) ) . truncate ( fractional_scale )
1919 ( seconds * fractional_operator ) . round ( 0 ) . to_i
2020 end
2121
2222 def quote_fractional ( value )
2323 return 0 if fractional_scale == 0
2424 frac_seconds = seconds_precision ( value )
25- seconds = ( frac_seconds . to_f / fractional_operator . to_f ) . round ( fractional_scale )
25+ seconds = ( frac_seconds . to_d / fractional_operator . to_d ) . round ( fractional_scale )
2626 seconds . to_d . to_s . split ( '.' ) . last . to ( fractional_scale -1 )
2727 end
2828
@@ -39,7 +39,7 @@ def fractional_operator
3939 end
4040
4141 def fractional_precision
42- 0.00333
42+ 0.00333 . to_d
4343 end
4444
4545 def fractional_scale
@@ -68,7 +68,7 @@ def fractional_digits
6868 end
6969
7070 def fractional_precision
71- 0.0000001
71+ 0.0000001 . to_d
7272 end
7373
7474 def fractional_scale
Original file line number Diff line number Diff line change @@ -223,14 +223,14 @@ class QuoteARBaseTest < ActiveRecord::TestCase
223223 coerce_tests! :test_quote_ar_object
224224 def test_quote_ar_object_coerced
225225 value = DatetimePrimaryKey . new ( id : @time )
226- assert_equal "'02-14-2017 12:34:56.79 '" , @connection . quote ( value )
226+ assert_equal "'02-14-2017 12:34:56.789 '" , @connection . quote ( value )
227227 end
228228
229229 # Use our date format.
230230 coerce_tests! :test_type_cast_ar_object
231231 def test_type_cast_ar_object_coerced
232232 value = DatetimePrimaryKey . new ( id : @time )
233- assert_equal "02-14-2017 12:34:56.79 " , @connection . type_cast ( value )
233+ assert_equal "02-14-2017 12:34:56.789 " , @connection . type_cast ( value )
234234 end
235235
236236 end
You can’t perform that action at this time.
0 commit comments