Sha256: d50699498036ec619b0884d1a53b5f2a61efa9b525256442dcf36466e827fc2c
Contents?: true
Size: 1.31 KB
Versions: 7
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true require "pathname" require "active_record" require "active_record/version" module ActiveRecord::Import ADAPTER_PATH = "activerecord-import/active_record/adapters" 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 # Loads the import functionality for a specific database adapter def self.require_adapter(adapter) require File.join(ADAPTER_PATH, "/#{base_adapter(adapter)}_adapter") rescue LoadError # fallback end # Loads the import functionality for the passed in ActiveRecord connection 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 end require 'activerecord-import/import' require 'activerecord-import/active_record/adapters/abstract_adapter' require 'activerecord-import/synchronize' require 'activerecord-import/value_sets_parser'
Version data entries
7 entries across 7 versions & 1 rubygems