diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-08 09:42:54 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-07-08 09:42:54 -0300 |
commit | 336be2bdf7dfa1b31879d0ab27e5f3101b351923 (patch) | |
tree | e48658928b4d9fc3b54330bac645d2b7949c3d58 /activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb | |
parent | e0c6b35dac32b6375c86d93e992a138dd627157e (diff) | |
parent | f6968bd601e38fb5060c7bc577331f97ed5e232c (diff) | |
download | rails-336be2bdf7dfa1b31879d0ab27e5f3101b351923.tar.gz rails-336be2bdf7dfa1b31879d0ab27e5f3101b351923.tar.bz2 rails-336be2bdf7dfa1b31879d0ab27e5f3101b351923.zip |
Merge pull request #16072 from sgrif/sg-xml-quoting
Don't rely on the sql type to quote XML columns in PG
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb | 11 |
1 files changed, 8 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 be598f997f..d2e12417a6 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb @@ -29,7 +29,6 @@ module ActiveRecord end when String case sql_type - when 'xml' then "xml '#{quote_string(value)}'" when /^bit/ case value when /\A[01]*\Z/ then "B'#{value}'" # Bit-string notation @@ -111,19 +110,25 @@ module ActiveRecord private def _quote(value) - if value.is_a?(Type::Binary::Data) + case value + when Type::Binary::Data "'#{escape_bytea(value.to_s)}'" + when OID::Xml::Data + "xml '#{quote_string(value.to_s)}'" else super end end def _type_cast(value) - if value.is_a?(Type::Binary::Data) + case value + when Type::Binary::Data # Return a bind param hash with format as binary. # See http://deveiate.org/code/pg/PGconn.html#method-i-exec_prepared-doc # for more information { value: value.to_s, format: 1 } + when OID::Xml::Data + value.to_s else super end |