instance method add_pg_decoders

Ruby on Rails edge

Since v5.0.7.2 Private — implementation detail, not part of the public API

Available in: v5.0.7.2 v5.1.7 v5.2.8.1 v6.0.6.1 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3.2 v8.0.5.1 v8.1.3.1 edge

Signature

add_pg_decoders()

No documentation comment.

Source
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 1379
        def add_pg_decoders
          @mapped_default_timezone = nil
          @timestamp_decoder = nil

          oids_by_name = OID::WellKnown.type_oids_for(server_version: database_version)
          coders_by_name = {
            "int2" => PG::TextDecoder::Integer,
            "int4" => PG::TextDecoder::Integer,
            "int8" => PG::TextDecoder::Integer,
            "oid" => PG::TextDecoder::Integer,
            "float4" => PG::TextDecoder::Float,
            "float8" => PG::TextDecoder::Float,
            "numeric" => PG::TextDecoder::Numeric,
            "bool" => PG::TextDecoder::Boolean,
            "timestamp" => PG::TextDecoder::TimestampUtc,
            "timestamptz" => PG::TextDecoder::TimestampWithTimeZone,
          }
          coders_by_name["date"] = PG::TextDecoder::Date if decode_dates
          coders_by_name["money"] = MoneyDecoder if decode_money
          coders_by_name["bytea"] = decode_bytea ? ByteaDecoder : ByteaMarker

          coders = coders_by_name.filter_map do |type_name, coder_class|
            next unless coder_class
            next unless oid = oids_by_name[type_name]

            coder_class.new(oid: oid, name: type_name)
          end

          map = PG::TypeMapByOid.new
          coders.each { |coder| map.add_coder(coder) }
          @raw_connection.type_map_for_results = map

          @type_map_for_results = PG::TypeMapByOid.new
          @type_map_for_results.default_type_map = map
          @type_map_for_results.add_coder(PG::TextDecoder::Bytea.new(oid: 17, name: "bytea"))
          @type_map_for_results.add_coder(MoneyDecoder.new(oid: 790, name: "money"))

          # extract timestamp decoder for use in update_typemap_for_default_timezone
          @timestamp_decoder = coders.find { |coder| coder.name == "timestamp" }
          update_typemap_for_default_timezone
        end

Defined in activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb line 1379 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close