Skip to content

Commit

Permalink
Unbreak support for the postgres and postgres-pr drivers after last c…
Browse files Browse the repository at this point in the history
…ommit
  • Loading branch information
jeremyevans committed Dec 1, 2011
1 parent 0ee17c3 commit 28cc339
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions doc/opening_databases.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ The following additional options are supported:

:charset :: Same as :encoding, :encoding takes precedence
:encoding :: Set the client_encoding to the given string
:connect_timeout :: Set the number of seconds to wait for a connection (default 20, only respected
if using the pg library).

=== sqlite

Expand Down
31 changes: 21 additions & 10 deletions lib/sequel/adapters/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,27 @@ def initialize(*args)
# client encoding for the connection.
def connect(server)
opts = server_opts(server)
connection_params = {
:host => opts[:host],
:port => opts[:port] || 5432,
:tty => '',
:dbname => opts[:database],
:user => opts[:user],
:password => opts[:password],
:connect_timeout => opts[:connect_timeout] || 20
}.delete_if { |key, value| blank_object?(value) }
conn = Adapter.connect(connection_params)
conn = if SEQUEL_POSTGRES_USES_PG
connection_params = {
:host => opts[:host],
:port => opts[:port] || 5432,
:tty => '',
:dbname => opts[:database],
:user => opts[:user],
:password => opts[:password],
:connect_timeout => opts[:connect_timeout] || 20
}.delete_if { |key, value| blank_object?(value) }
Adapter.connect(connection_params)
else
Adapter.connect(
(opts[:host] unless blank_object?(opts[:host])),
opts[:port] || 5432,
nil, '',
opts[:database],
opts[:user],
opts[:password]
)
end
if encoding = opts[:encoding] || opts[:charset]
if conn.respond_to?(:set_client_encoding)
conn.set_client_encoding(encoding)
Expand Down

0 comments on commit 28cc339

Please sign in to comment.