diff options
author | Akshay Vishnoi <akshay.vishnoi@vinsol.com> | 2013-11-29 16:42:26 +0530 |
---|---|---|
committer | Akshay Vishnoi <akshay.vishnoi@vinsol.com> | 2013-11-29 16:42:26 +0530 |
commit | 33b69c4f4cd9fd14fc84b2e807b14bb8bce4ebc1 (patch) | |
tree | 236b6cbe5963ec91cb0e0838636691986629ed1c | |
parent | e4c0a225ae029af91d26735d8085a09d6d64859e (diff) | |
download | rails-33b69c4f4cd9fd14fc84b2e807b14bb8bce4ebc1.tar.gz rails-33b69c4f4cd9fd14fc84b2e807b14bb8bce4ebc1.tar.bz2 rails-33b69c4f4cd9fd14fc84b2e807b14bb8bce4ebc1.zip |
#type_cast - improve performance & readability
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index dcbc3466b2..7dd6daabd5 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -207,9 +207,14 @@ module ActiveRecord 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 |