Skip to content

Commit

Permalink
Make postgres adapter work with postgres-pr 0.7.0 (Fixes #1074)
Browse files Browse the repository at this point in the history
This fixes an ArgumentError when trying to use Sequel with postgres-pr
0.7.0, because that started shipping with a pg.rb file.

Note that postgres-pr 0.7.0 doesn't work on ruby 2.0+ due to
multibyte escape issues in a regexp.  For years I've only been
testing using my postgres-pr fork.  Mention that fork in the doc
so that people are aware of it.
  • Loading branch information
jeremyevans committed Sep 2, 2015
1 parent 436d0be commit a3c7908
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
=== HEAD

* Make postgres adapter work with postgres-pr 0.7.0 (jeremyevans) (#1074)

=== 4.26.0 (2015-09-01)

* Make Dataset#== not consider frozen status in determining equality (jeremyevans)
Expand Down
4 changes: 3 additions & 1 deletion doc/opening_databases.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ The Sequel postgres adapter works with the pg, postgres, and postgres-pr ruby li
The pg library is the best supported, as it supports real bound variables and prepared statements.
If the pg library is being used, Sequel will also attempt to load the sequel_pg library, which is
a C extension that optimizes performance when Sequel is used with pg. All users of Sequel who
use pg are encouraged to install sequel_pg.
use pg are encouraged to install sequel_pg. For users who want to use postgres-pr to avoid issues
with C extensions, it is recommended to use jeremyevans-postgres-pr, which fixes many issues in
the upstream postgres-pr gem, and is regularly tested with Sequel.

The following additional options are supported:

Expand Down
4 changes: 4 additions & 0 deletions lib/sequel/adapters/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

begin
require 'pg'

# Work around postgres-pr 0.7.0+ which ships with a pg.rb file
raise LoadError unless defined?(PGconn::CONNECTION_OK)

SEQUEL_POSTGRES_USES_PG = true
rescue LoadError => e
SEQUEL_POSTGRES_USES_PG = false
Expand Down

0 comments on commit a3c7908

Please sign in to comment.