PG :: InvalidParameterValue:错误:参数“ client_min_messages”的值无效:“ panic” [英] PG::InvalidParameterValue: ERROR: invalid value for parameter "client_min_messages": "panic"

查看:1382
本文介绍了PG :: InvalidParameterValue:错误:参数“ client_min_messages”的值无效:“ panic”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rake db:create显示错误PG :: InvalidParameterValue:错误:参数 client_min_messages的值无效: panic
提示:可用值:debug5,debug4,debug3,debug2,debug1,日志,通知,警告,错误。

rake db:create showing error PG::InvalidParameterValue: ERROR: invalid value for parameter "client_min_messages": "panic" HINT: Available values: debug5, debug4, debug3, debug2, debug1, log, notice, warning, error.

捆绑安装后尝试运行rake db:create commond。
在config文件夹中创建的database.yml文件,请在下面找到:

After bundle install tried to run rake db:create commond. Created database.yml file inside the config folder please find below :

development:
  adapter: postgresql
  encoding: utf8
  database: thor_development1
  username: postgres
  password:
  host: localhost

test:
  adapter: postgresql
  encoding: utf8
  database: thor_test1
  username: postgres
  password:
  host: localhost



PG::InvalidParameterValue: ERROR:  invalid value for parameter "client_min_messages": "panic"
HINT:  Available values: debug5, debug4, debug3, debug2, debug1, log, notice, warning, error.
: SET client_min_messages TO 'panic'
/Users/galaxy/.rvm/gems/ruby-2.1.2@folderName/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `async_exec'
/Users/galaxy/.rvm/gems/ruby-2.1.2@folderName/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
/Users/galaxy/.rvm/gems/ruby-2.1.2@folderName/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/Users/galaxy/.rvm/gems/ruby-2.1.2@folderName/gems/activesupport-4.1.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/galaxy/.rvm/gems/ruby-2.1.2@folderName/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/Users/galaxy/.rvm/gems/ruby-2.1.2@folderName/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
/Users/galaxy/.rvm/gems/ruby-2.1.2@folderName/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql/schema_statements.rb:274:in `client_min_messages='
/Users/galaxy/.rvm/gems/ruby-2.1.2@folderName/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:634:in `set_standard_conforming_strings'
/Users/galaxy/.rvm/gems/ruby-2.1.2@folderName/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:914:in `configure_connection'
/Users/galaxy/.rvm/gems/ruby-2.1.2@folderName/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:895:in `connect'
/Users/galaxy/.rvm/gems/ruby-2.1.2@folderName/gems/activerecord-4.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'

尝试在macOS Catalina中安装

Trying to install in macOS Catalina

推荐答案

要使其与PostgreSQL 12版一起使用,我先打了补丁PostgreSQLA dapter类别,以警告消息代替恐慌。
注意,如果您可以将activerecord gem升级到4.2.6或更高版本,则不需要此猴子补丁。我必须这样做,因为我的项目取决于gem activerecord-3.2.22.5

To make it work with PostgreSQL version 12, I monkey patched PostgreSQLAdapter class to replace 'panic' with 'warning' message. Note, if you can upgrade activerecord gem to 4.2.6 or higher versions you don't need to have this monkey patch. I had to do this because my project depends on gem activerecord-3.2.22.5

require 'active_record/connection_adapters/postgresql_adapter'

class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
  def set_standard_conforming_strings
    old, self.client_min_messages = client_min_messages, 'warning'
    execute('SET standard_conforming_strings = on', 'SCHEMA') rescue nil
  ensure
    self.client_min_messages = old
  end
end

这篇关于PG :: InvalidParameterValue:错误:参数“ client_min_messages”的值无效:“ panic”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆