aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-04 12:32:44 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-04 12:32:44 -0300
commit295f2bd1320b5dac6aa34e12baa670eb00e979cc (patch)
tree72be38bb743b115d60be98bdb9d3b2ab610194ee /activerecord/lib/active_record
parenta8e1538b6032be16c499a7049c2eaa1eeb2265ac (diff)
parentefc436df2092bacc896dbf66ddc332aeafe42e72 (diff)
downloadrails-295f2bd1320b5dac6aa34e12baa670eb00e979cc.tar.gz
rails-295f2bd1320b5dac6aa34e12baa670eb00e979cc.tar.bz2
rails-295f2bd1320b5dac6aa34e12baa670eb00e979cc.zip
Merge pull request #16037 from sgrif/sg-money-quoting
Remove unneccessary special case for money in quoting
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb7
-rw-r--r--activerecord/lib/active_record/type/string.rb8
2 files changed, 4 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
index 7c485eb9d0..39b36731cd 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
@@ -34,13 +34,6 @@ module ActiveRecord
else
super
end
- when Numeric
- if sql_type == 'money' || [:string, :text].include?(column.type)
- # Not truly string input, so doesn't require (or allow) escape string syntax.
- "'#{value}'"
- else
- super
- end
when String
case sql_type
when 'xml' then "xml '#{quote_string(value)}'"
diff --git a/activerecord/lib/active_record/type/string.rb b/activerecord/lib/active_record/type/string.rb
index 14b03dcb2d..8cc533bc41 100644
--- a/activerecord/lib/active_record/type/string.rb
+++ b/activerecord/lib/active_record/type/string.rb
@@ -16,10 +16,10 @@ module ActiveRecord
end
def type_cast_for_database(value)
- if value.is_a?(::String)
- ::String.new(value)
- else
- super
+ case value
+ when ::Numeric then value.to_s
+ when ::String then ::String.new(value)
+ else super
end
end