I fixed an issue on my rails project locally (with postgres config) while adding in database.yml this statement:
test:
prepared_statements: false
We were worried about brittleness and maintaining consistency between staging/production (using DATABASE_URL on Heroku) and development/test (using database.yml/database.example.yml).
Inspired by Rails' tests, we put this in config/initializers/disable_prepared_statements.rb:
ActiveRecord::Base.establish_connection(
ActiveRecord::Base.remove_connection.merge(
:prepared_statements => false
)
)
remove_connection
returns a hash of the connection parameters of the connection being removed. This should let any database.yml or DATABASE_URL continue working.