diff options
author | Thiago Pradi <thiago.pradi@gmail.com> | 2012-09-02 18:56:45 -0300 |
---|---|---|
committer | Thiago Pradi <thiago.pradi@gmail.com> | 2012-09-09 16:23:52 -0300 |
commit | 652107e2e137cf18cf517d96ee9063660e86d686 (patch) | |
tree | 097701bdc014fd6cb5d3af1c59ef668c17db8fb2 /activerecord/lib | |
parent | cabab374bfc6c1bd1d783ecc3c674047f17523c6 (diff) | |
download | rails-652107e2e137cf18cf517d96ee9063660e86d686.tar.gz rails-652107e2e137cf18cf517d96ee9063660e86d686.tar.bz2 rails-652107e2e137cf18cf517d96ee9063660e86d686.zip |
ConnectionAdapters::Column.type_cast_code should always convert values to integer calling #to_i
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/column.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb index 393a3b623a..943f18844d 100644 --- a/activerecord/lib/active_record/connection_adapters/column.rb +++ b/activerecord/lib/active_record/connection_adapters/column.rb @@ -75,7 +75,7 @@ module ActiveRecord case type when :string, :text then value - when :integer then value.to_i rescue value ? 1 : 0 + when :integer then value.to_i when :float then value.to_f when :decimal then klass.value_to_decimal(value) when :datetime, :timestamp then klass.string_to_time(value) @@ -92,7 +92,7 @@ module ActiveRecord case type when :string, :text then var_name - when :integer then "(#{var_name}.to_i rescue #{var_name} ? 1 : 0)" + when :integer then "(#{var_name}.to_i)" when :float then "#{var_name}.to_f" when :decimal then "#{klass}.value_to_decimal(#{var_name})" when :datetime, :timestamp then "#{klass}.string_to_time(#{var_name})" |