Browse files

Postgresql: restore previous behaviour regarding to nil values in con…

…nection specification Hash
  • Loading branch information...
1 parent 8aaf971 commit 92a3c487bb0d125c437e53a7f45c31fcca97f2d9 @larskanis larskanis committed Jan 5, 2012
Showing with 1 addition and 0 deletions.
  1. +1 −0 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -16,6 +16,7 @@ def postgresql_connection(config) # :nodoc:
conn_params = config.except(:statement_limit, :encoding, :min_messages,
:schema_search_path, :schema_order,
:adapter, :pool, :wait_timeout)
+ conn_params.delete_if { |k,v| v.nil? }
# Map ActiveRecords param names to PGs.
conn_params[:user] = conn_params.delete(:username) if conn_params[:username]

2 comments on commit 92a3c48


Thanks for fixing this. I wasted a few hours trying to deploy a simple Sinatra app to Heroku that refused to connect to the shared database.

I kept getting this error but couldn't figure out why:
ActiveRecord::StatementInvalid: PGError: ERROR: invalid value for parameter "client_min_messages": ""

Since I wasn't setting a value for :min_messages, it was being set to "", and hence the error.


:min_messages isn't touched by this commit - only the values that are used for PGconn.connect. But you're right, also for the other parameters, nil values should be handled equal to not defined keys for consistency.

Please sign in to comment.