Skip to content

Commit

Permalink
Merge branch 'jjoos-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
larskanis committed Sep 5, 2017
2 parents cb2618b + 7b12ae6 commit ae4a783
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pg/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def self::parse_connect_args( *args )

if args.length == 1
case args.first
when URI, URI.regexp
when URI, /\A#{URI.regexp}\z/
uri = URI(args.first)
options.merge!( Hash[URI.decode_www_form( uri.query )] ) if uri.query
when /=/
Expand Down
13 changes: 13 additions & 0 deletions spec/pg/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@
expect( described_class.parse_connect_args ).to eq( '' )
end

it "connects successfully with connection string" do
conninfo_with_colon_in_password = "host=localhost user=a port=555 dbname=test password=a:a"

string = described_class.parse_connect_args( conninfo_with_colon_in_password )

expect( string ).to be_a( String )
expect( string ).to match( %r{(^|\s)user=a} )
expect( string ).to match( %r{(^|\s)password=a:a} )
expect( string ).to match( %r{(^|\s)host=localhost} )
expect( string ).to match( %r{(^|\s)port=555} )
expect( string ).to match( %r{(^|\s)dbname=test} )
end

it "connects successfully with connection string" do
tmpconn = described_class.connect( @conninfo )
expect( tmpconn.status ).to eq( PG::CONNECTION_OK )
Expand Down

0 comments on commit ae4a783

Please sign in to comment.