Sha256: 29c13e5bcb6f8202f78ef9f0fdd2b9191b9e99e6c6721aff5e753bcfb70e5684
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true require 'chrono_model' module ActiveRecord # TODO: Remove when dropping Rails < 7.2 compatibility module ConnectionHandling def chronomodel_adapter_class ChronoModel::Adapter end # Install the new adapter in ActiveRecord. This approach is required because # the PG adapter defines +add_column+ itself, thus making impossible to use # super() in overridden Module methods. # def chronomodel_connection(config) # :nodoc: return chronomodel_adapter_class.new(config) if ActiveRecord::VERSION::STRING >= '7.1' conn_params = config.symbolize_keys.compact # Map ActiveRecords param names to PGs. conn_params[:user] = conn_params.delete(:username) if conn_params[:username] conn_params[:dbname] = conn_params.delete(:database) if conn_params[:database] # Forward only valid config params to PG::Connection.connect. valid_conn_param_keys = PG::Connection.conndefaults_hash.keys + [:requiressl] conn_params.slice!(*valid_conn_param_keys) conn = PG.connect(conn_params) adapter = ChronoModel::Adapter.new(conn, logger, conn_params, config) unless adapter.chrono_supported? raise ChronoModel::Error, 'Your database server is not supported by ChronoModel. ' \ 'Currently, only PostgreSQL >= 9.3 is supported.' end adapter.chrono_setup! adapter end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chrono_model-3.0.1 | lib/active_record/connection_adapters/chronomodel_adapter.rb |