instance method
add_pg_decoders
Ruby on Rails 5.2.8.1
Since v5.2.8.1 PrivateSignature
add_pg_decoders()
No documentation comment.
Source
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 810
def add_pg_decoders
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,
"bool" => PG::TextDecoder::Boolean,
}
known_coder_types = coders_by_name.keys.map { |n| quote(n) }
query = <<-SQL % known_coder_types.join(", ")
SELECT t.oid, t.typname
FROM pg_type as t
WHERE t.typname IN (%s)
SQL
coders = execute_and_clear(query, "SCHEMA", []) do |result|
result
.map { |row| construct_coder(row, coders_by_name[row["typname"]]) }
.compact
end
map = PG::TypeMapByOid.new
coders.each { |coder| map.add_coder(coder) }
@connection.type_map_for_results = map
end
Defined in activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb line 810
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter