Permalink
Browse files

#type_cast - improve performance & readability

  • Loading branch information...
1 parent e4c0a22 commit 33b69c4f4cd9fd14fc84b2e807b14bb8bce4ebc1 @akshay-vishnoi akshay-vishnoi committed Nov 29, 2013
Showing with 8 additions and 3 deletions.
  1. +8 −3 activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
View
11 activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -207,9 +207,14 @@ def supports_index_sort_order?
end
def type_cast(value, column)
- return super unless value == true || value == false
-
- value ? 1 : 0
+ case value
+ when TrueClass
+ 1
+ when FalseClass
+ 0
+ else
+ super
+ end
end
# MySQL 4 technically support transaction isolation, but it is affected by a bug

0 comments on commit 33b69c4

Please sign in to comment.