Module: ActiveRecord::Import

Defined in:
lib/activerecord-import/import.rb,
lib/activerecord-import/version.rb,
lib/activerecord-import/value_sets_parser.rb,
lib/activerecord-import/base.rb

Overview

:nodoc:

Defined Under Namespace

Modules: AbstractAdapter, Connection, ConnectionAdapters, EMMysql2Adapter, ImportSupport, Mysql2Adapter, MysqlAdapter, OnDuplicateKeyUpdateSupport, PostgreSQLAdapter, SQLite3Adapter, TrilogyAdapter Classes: MissingColumnError, Result, Validator, ValueSetTooLargeError, ValueSetsBytesParser, ValueSetsRecordsParser

Constant Summary collapse

VERSION =
"1.8.1"
ADAPTER_PATH =
"activerecord-import/active_record/adapters"

Class Method Summary collapse

Class Method Details

.base_adapter(adapter) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/activerecord-import/base.rb', line 10

def self.base_adapter(adapter)
  case adapter
  when 'mysql2_makara' then 'mysql2'
  when 'mysql2spatial' then 'mysql2'
  when 'spatialite' then 'sqlite3'
  when 'postgresql_makara' then 'postgresql'
  when 'makara_postgis' then 'postgresql'
  when 'postgis' then 'postgresql'
  when 'cockroachdb' then 'postgresql'
  else adapter
  end
end

.load_from_connection_pool(connection_pool) ⇒ Object

Loads the import functionality for the passed in ActiveRecord connection



31
32
33
34
35
36
37
38
39
# File 'lib/activerecord-import/base.rb', line 31

def self.load_from_connection_pool(connection_pool)
  adapter =
    if connection_pool.respond_to?(:db_config) # ActiveRecord >= 6.1
      connection_pool.db_config.adapter
    else
      connection_pool.spec.config[:adapter]
    end
  require_adapter adapter
end

.require_adapter(adapter) ⇒ Object

Loads the import functionality for a specific database adapter



24
25
26
27
28
# File 'lib/activerecord-import/base.rb', line 24

def self.require_adapter(adapter)
  require File.join(ADAPTER_PATH, "/#{base_adapter(adapter)}_adapter")
rescue LoadError
  # fallback
end