From f6968bd601e38fb5060c7bc577331f97ed5e232c Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sun, 6 Jul 2014 14:53:43 -0600 Subject: Don't rely on the sql type to quote XML columns in PG --- .../connection_adapters/postgresql/oid/xml.rb | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 activerecord/lib/active_record/connection_adapters/postgresql/oid/xml.rb (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/oid/xml.rb') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/xml.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/xml.rb new file mode 100644 index 0000000000..7323f12763 --- /dev/null +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/xml.rb @@ -0,0 +1,32 @@ +module ActiveRecord + module ConnectionAdapters + module PostgreSQL + module OID # :nodoc: + class Xml < Type::String # :nodoc: + def type + :xml + end + + def text? + false + end + + def type_cast_for_database(value) + return unless value + Data.new(super) + end + + class Data # :nodoc: + def initialize(value) + @value = value + end + + def to_s + @value + end + end + end + end + end + end +end -- cgit v1.2.3