Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

9253: Before writing a numeric attribute value, ActiveRecord does an …

…implicit

conversion of boolean types (true => 1 and false => 0). If the numeric value
being assigned is a BigDecimal, then ActiveRecord compares a BigDecimal to
true and false. This is known to be very slow in Ruby 1.9.3.
  • Loading branch information...
commit 0c0ee13a1cb6a8156c7a3bf7334efc6ff8c04c5d 1 parent f8c8ad5
warnickr warnickr authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 activerecord/lib/active_record/connection_adapters/column.rb
9 activerecord/lib/active_record/connection_adapters/column.rb
View
@@ -74,12 +74,13 @@ def binary?
def type_cast_for_write(value)
return value unless number?
- if value == false
+ case value
+ when FalseClass
0
- elsif value == true
+ when TrueClass
1
- elsif value.is_a?(String) && value.blank?
- nil
+ when String
+ value.presence
else
value
end
Please sign in to comment.
Something went wrong with that request. Please try again.