Skip to content

Commit

Permalink
support connect_timeout for postgresql driver. Use hash params instea…
Browse files Browse the repository at this point in the history
…d of array
  • Loading branch information
Gleb Pomykalov authored and jeremyevans committed Dec 1, 2011
1 parent 8bdeb27 commit 0ee17c3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/sequel/adapters/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,16 @@ def initialize(*args)
# client encoding for the connection.
def connect(server)
opts = server_opts(server)
conn = Adapter.connect(
(opts[:host] unless blank_object?(opts[:host])),
opts[:port] || 5432,
nil, '',
opts[:database],
opts[:user],
opts[:password]
)
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)
if encoding = opts[:encoding] || opts[:charset]
if conn.respond_to?(:set_client_encoding)
conn.set_client_encoding(encoding)
Expand Down

0 comments on commit 0ee17c3

Please sign in to comment.