rails: PGconn, PGresult, and PGError constants are deprecated

(I couldn’t find another issue about this, sorry if it has already been addressed)

Using both Rails 5.1.0 and 5.1.2.rc1, I get the following message on boot:

The PGconn, PGresult, and PGError constants are deprecated, and will be
removed as of version 1.0.

You should use PG::Connection, PG::Result, and PG::Error instead, respectively.
Called from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:258:in `load_dependency'

My pg version is 0.21.0.

Downgrading to 0.20 makes the warning go away.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 28
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Confirmed. Locked to pg 0.20 and now clean as a whistle.

My problem was the seuqel_pg wasn’t updated to use the new constants. I’m awaiting that gem’s next update. You can also downgrade to pg 0.20 but that’s not worth the tradeoff to get rid of an otherwise harmless warning message.

According to @y-yagi’s comment, only rails 5.0.x and rails 5.1.x have been updated to be aware of the new constants. If you’re on rails 4.2.x you need to either lock to pg 0.20 or upgrade to Rails 5.

I am facing this issue with rails 5.0.1, pg 0.21.0.

Yes exactly I have found the solution after many searching, thanks to the Stack Overflow I have edited Gemfile like

gem 'pg', '~> 0.11'

Then updated bundle

https://stackoverflow.com/a/49150265/4172515

The above correspondence is included in Rails 5.0.3 or later. Please update Rails.

You’re right, this was due to the sequel_pg gem, not Rails. Confusing because the only line in the warning stack trace was from activesupport-5.1.1

@kniazeu we need to lock the PG gem to 0.20 to remove the deprecation messages.