diff options
author | Łukasz Strzałkowski <lukasz.strzalkowski@gmail.com> | 2013-03-12 16:05:01 +0100 |
---|---|---|
committer | Łukasz Strzałkowski <lukasz.strzalkowski@gmail.com> | 2013-03-12 16:13:01 +0100 |
commit | aae89ee8607a802557b4877feb995204e0b58fed (patch) | |
tree | dad783f33dc8510d26c13328c5015c41b608af14 /activerecord/lib | |
parent | d25a82280f977664e3b3d49c13bb68502718f6e2 (diff) | |
download | rails-aae89ee8607a802557b4877feb995204e0b58fed.tar.gz rails-aae89ee8607a802557b4877feb995204e0b58fed.tar.bz2 rails-aae89ee8607a802557b4877feb995204e0b58fed.zip |
Cast number to string in Postgres
fixes #9170
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb index 47e2e3928f..43f991b362 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb @@ -51,9 +51,12 @@ module ActiveRecord super end when Numeric - return super unless column.sql_type == 'money' - # Not truly string input, so doesn't require (or allow) escape string syntax. - "'#{value}'" + if column.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 column.sql_type when 'bytea' then "'#{escape_bytea(value)}'" |