PG::Coder.new(hash) 已弃用。请改用关键字参数

ala*_*sia 7 postgresql ruby-on-rails

自从更新到 pg 1.5.2 以来,我们一直在控制台中看到这个警告,来自.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/connection_adapters/postgresql_adapter.rb:980:in 'new'.

Ruby 3.2.2、Rails 7.0.4.3

我在谷歌上没有找到太多信息,有人知道如何解决它吗?

def update_typemap_for_default_timezone
  if @default_timezone != ActiveRecord.default_timezone && @timestamp_decoder
    decoder_class = ActiveRecord.default_timezone == :utc ?
      PG:: TextDecoder::TimestampUtc :
      PG: :TextDecoder::TimestampWithoutTimeZone

    @timestamp_decoder = decoder_class. new(@timestamp_decoder. to_h)
    @connection.type_map_for_results.add_coder (@timestamp_decoder)

    @default_timezone = ActiveRecord.default_timezone

    # if default timezone has changed, we need to reconfigure the connection
    # (specifically, the session time zone)
    configure_connection
  end
end
Run Code Online (Sandbox Code Playgroud)

我用谷歌搜索,但没有找到任何东西

ala*_*sia 8

发布此内容后,我立即找到了答案,但这对其他人可能有帮助

问题: https: //github.com/rails/rails/issues/48046 PR: https: //github.com/rails/rails/pull/48048

已经合并并将在新的补丁版本中发布。大家记得更新哦!