Module: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::ByteaDecodeDetection

Included in:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
Defined in:
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#unescape_bytea(string) ⇒ Object



1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
# File 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb', line 1287

def unescape_bytea(string)
  if string.instance_variable_get(:@ar_pg_bytea_decoded) == true
    ActiveRecord.deprecator.warn(<<~MSG.squish)
      unescape_bytea called on a query result value that has already been
      automatically unescaped due to `config.active_record.postgresql_adapter_decode_bytea`.
      In a future Rails release, this will double-unescape the value as
      instructed, which could cause data corruption.
    MSG

    result = string.dup
    result.remove_instance_variable(:@ar_pg_bytea_decoded)
    return result
  end

  super
end