aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2015-03-25 16:11:22 +0100
committerLars Kanis <lars@greiz-reinsdorf.de>2015-03-25 19:59:05 +0100
commit86a23faa1a82a3e7a2cdf2df01eb6eb18dd3d6f6 (patch)
treecc2266e2c46292c4dd953eaf90f5e5f89b7a991d /activerecord/lib/active_record
parent348377da4d623a81b570b2bf46e6ef9e5ee4e12f (diff)
downloadrails-86a23faa1a82a3e7a2cdf2df01eb6eb18dd3d6f6.tar.gz
rails-86a23faa1a82a3e7a2cdf2df01eb6eb18dd3d6f6.tar.bz2
rails-86a23faa1a82a3e7a2cdf2df01eb6eb18dd3d6f6.zip
PostgreSQL, Replace static connection param list by the one built into libpq.
This makes the connection adapter future-proof regarding to new parameters. To maintain backward compatibility, :requiressl is added by hand. It is deprecated by PostgreSQL since 2003, but still accepted by libpq.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 96a3ac7c31..f136338558 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -20,12 +20,6 @@ require 'ipaddr'
module ActiveRecord
module ConnectionHandling # :nodoc:
- VALID_CONN_PARAMS = [:host, :hostaddr, :port, :dbname, :user, :password, :connect_timeout,
- :client_encoding, :options, :application_name, :fallback_application_name,
- :keepalives, :keepalives_idle, :keepalives_interval, :keepalives_count,
- :tty, :sslmode, :requiressl, :sslcompression, :sslcert, :sslkey,
- :sslrootcert, :sslcrl, :requirepeer, :krbsrvname, :gsslib, :service]
-
# Establishes a connection to the database that's used by all Active Record objects
def postgresql_connection(config)
conn_params = config.symbolize_keys
@@ -37,7 +31,8 @@ module ActiveRecord
conn_params[:dbname] = conn_params.delete(:database) if conn_params[:database]
# Forward only valid config params to PGconn.connect.
- conn_params.keep_if { |k, _| VALID_CONN_PARAMS.include?(k) }
+ valid_conn_param_keys = PGconn.conndefaults_hash.keys + [:requiressl]
+ conn_params.slice!(*valid_conn_param_keys)
# The postgres drivers don't allow the creation of an unconnected PGconn object,
# so just pass a nil connection object for the time being.