如何使用postgres数据库在heroku中禁用准备好的语句 [英] How to disable prepared statement in heroku with postgres database
问题描述
在添加database.yml时,我在本地的rails项目中修复了一个问题(使用postgres配置)。
I fixed an issue on my rails project locally (with postgres config) while adding in database.yml this statement:
test:
prepared_statements: false
我修复的错误与以下问题有关:
The bug that I fixed was related to this issue:
PG::ProtocolViolation: ERROR: bind message supplies 2 parameters, but prepared statement "a24" requires 1
现在,我想用Hergre上的postgres数据库在我的生产应用程序上修复它。我不知道如何禁用准备好的语句,因为database.yml是自动生成的。我试图附加:
Now, I want to fix it on my production app hosted on Heroku with a postgres database. I don't know how to disable prepared statement as the database.yml is automatically generated. I tried to append:
/database?prepared_statements=false
到我的数据库的URI,但是最后以一个错误的DATABSE_URL结尾,因此我无法连接到我的数据库。
to my database's URI but it ends up with a DATABSE_URL that is wrong and so I can't connect to my database.
禁用prepared_statement的过程和正确的语法是什么?
What is the process and the right syntax to disable prepared_statement?
推荐答案
自2014年2月19日起,heroku 不再覆盖 database.yml
,因此您可以在生产
和分期
(或<
As of Feb 19th 2014, heroku no longer overrides database.yml
so you can turn off prepared statements in your production
and staging
(or default
) block of the database.yml
file as recommended by the latest docs:
default: &default
adapter: postgresql
encoding: unicode
pool: 5
prepared_statements: false
development:
<<: *default
database: myapp_development
test:
<<: *default
database: myapp_test
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
pool: <%= ENV['DB_POOL'] || ENV['MAX_THREADS'] || 5 %>
staging:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
pool: <%= ENV['DB_POOL'] || ENV['MAX_THREADS'] || 5 %>
这篇关于如何使用postgres数据库在heroku中禁用准备好的语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!