Class: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Bytea
- Inherits:
-
Type::Binary
- Object
- ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Bytea
- Defined in:
- activerecord/lib/active_record/connection_adapters/postgresql/oid/bytea.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#deserialize(value) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/bytea.rb', line 8 def deserialize(value) case value when nil return when Type::Binary::Data result = value.to_s if result.instance_variable_defined?(:@ar_pg_bytea_decoded) result = result.dup result.remove_instance_variable(:@ar_pg_bytea_decoded) end return result when String if value.instance_variable_get(:@ar_pg_bytea_decoded) result = value.dup result.remove_instance_variable(:@ar_pg_bytea_decoded) return result elsif value.encoding == Encoding::BINARY && !value.instance_variable_defined?(:@ar_pg_bytea_decoded) ActiveRecord.deprecator.warn(<<~MSG.squish) bytea column received a binary string for unescaping. In Rails 8.3, binary strings will be treated as already unescaped. MSG end else value = super end PG::Connection.unescape_bytea(value) end |