Skip to content

Commit

Permalink
Add a way to disable the deprecation warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
ged committed Jun 13, 2017
1 parent c91947a commit c31d8a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .hoerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
exclude: !ruby/regexp /(?:\.(hg|hoe|bundle|irb|pry|ruby-(version|gemset)|gems|tm|DS_Store|travis\.yml)|sample|tmp|certs|build|lib/.*(so|dll)|appveyor\.yml|misc|Gemfile|pg\.gemspec)/
exclude: !ruby/regexp /(?:\.(hg|hoe|bundle|irb|pry|ruby-(version|gemset)|gems|tm|DS_Store|travis\.yml)|sample|vendor|tmp|certs|build|lib/.*(so|dll)|appveyor\.yml|misc|Gemfile|pg\.gemspec)/
13 changes: 8 additions & 5 deletions lib/pg/deprecated_constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
#encoding: utf-8

# Warn about use of deprecated constants when this is autoloaded
callsite = caller(3).first
unless ENV['PG_SKIP_DEPRECATION_WARNING']
callsite = caller(3).first

warn <<END_OF_WARNING
warn <<-END_OF_WARNING
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 #{callsite}
END_OF_WARNING

You can disable this warning by setting the PG_SKIP_DEPRECATION_WARNING environment
variable.
Called from #{callsite}
END_OF_WARNING
end

PGconn = PG::Connection
PGresult = PG::Result
Expand Down

0 comments on commit c31d8a2

Please sign in to comment.