Flowdock
method

initialize_type_map

Importance_0
initialize_type_map(type_map) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 794
        def initialize_type_map(type_map)
          result = execute('SELECT oid, typname, typelem, typdelim, typinput FROM pg_type', 'SCHEMA')
          leaves, nodes = result.partition { |row| row['typelem'] == '0' }

          # populate the leaf nodes
          leaves.find_all { |row| OID.registered_type? row['typname'] }.each do |row|
            type_map[row['oid'].to_i] = OID::NAMES[row['typname']]
          end

          records_by_oid = result.group_by { |row| row['oid'] }

          arrays, nodes = nodes.partition { |row| row['typinput'] == 'array_in' }

          # populate composite types
          nodes.each do |row|
            add_oid row, records_by_oid, type_map
          end

          # populate array types
          arrays.find_all { |row| type_map.key? row['typelem'].to_i }.each do |row|
            array = OID::Array.new  type_map[row['typelem'].to_i]
            type_map[row['oid'].to_i] = array
          end
        end
Register or log in to add new notes.