aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-09-09 13:19:39 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-09-09 13:19:39 -0700
commit924ad60151db70a3a63889a156c4d9f9cfeda431 (patch)
treed9f4cbd3c86c7d3ee39b869f33747b8099f9e935 /activerecord/lib/active_record/connection_adapters
parent146eaf381822f3d908809111621bf6242c510668 (diff)
parent652107e2e137cf18cf517d96ee9063660e86d686 (diff)
downloadrails-924ad60151db70a3a63889a156c4d9f9cfeda431.tar.gz
rails-924ad60151db70a3a63889a156c4d9f9cfeda431.tar.bz2
rails-924ad60151db70a3a63889a156c4d9f9cfeda431.zip
Merge pull request #7582 from tchandy/fix_type_cast_code
type_cast_code should always convert values to integer calling #to_i
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/column.rb4
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 ef8ee6cab0..d38e8464c5 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})"