Skip to content

Commit

Permalink
Postgresql: restore previous behaviour regarding to nil values in con…
Browse files Browse the repository at this point in the history
…nection specification Hash
  • Loading branch information
larskanis committed Jan 5, 2012
1 parent 8aaf971 commit 92a3c48
Showing 1 changed file with 1 addition and 0 deletions.
Expand Up @@ -16,6 +16,7 @@ def postgresql_connection(config) # :nodoc:
conn_params = config.except(:statement_limit, :encoding, :min_messages, conn_params = config.except(:statement_limit, :encoding, :min_messages,
:schema_search_path, :schema_order, :schema_search_path, :schema_order,
:adapter, :pool, :wait_timeout) :adapter, :pool, :wait_timeout)
conn_params.delete_if { |k,v| v.nil? }


# Map ActiveRecords param names to PGs. # Map ActiveRecords param names to PGs.
conn_params[:user] = conn_params.delete(:username) if conn_params[:username] conn_params[:user] = conn_params.delete(:username) if conn_params[:username]
Expand Down

2 comments on commit 92a3c48

@mokolabs
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@larskanis
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

: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.