Class: ActiveRecord::ConnectionAdapters::Redshift::OID::TypeMapInitializer
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::Redshift::OID::TypeMapInitializer
- Defined in:
- lib/active_record/connection_adapters/redshift/oid/type_map_initializer.rb
Overview
This class uses the data from PostgreSQL pg_type table to build the OID -> Type mapping.
- OID is an integer representing the type.
- Type is an OID::Type object.
This class has side effects on the store
passed during initialization.
Instance Method Summary collapse
-
#initialize(store, run_complex_types = true) ⇒ TypeMapInitializer
constructor
:nodoc:.
- #run(records) ⇒ Object
Constructor Details
#initialize(store, run_complex_types = true) ⇒ TypeMapInitializer
:nodoc:
11 12 13 14 |
# File 'lib/active_record/connection_adapters/redshift/oid/type_map_initializer.rb', line 11 def initialize(store, run_complex_types = true) @store = store @run_complex_types = run_complex_types end |
Instance Method Details
#run(records) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_record/connection_adapters/redshift/oid/type_map_initializer.rb', line 16 def run(records) nodes = records.reject { |row| @store.key? row['oid'].to_i } mapped, nodes = nodes.partition { |row| @store.key? row['typname'] } ranges, nodes = nodes.partition { |row| row['typtype'] == 'r'.freeze } enums, nodes = nodes.partition { |row| row['typtype'] == 'e'.freeze } domains, nodes = nodes.partition { |row| row['typtype'] == 'd'.freeze } arrays, nodes = nodes.partition { |row| row['typinput'] == 'array_in'.freeze } composites, nodes = nodes.partition { |row| row['typelem'].to_i != 0 } mapped.each { |row| register_mapped_type(row) } end |