-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass URI directly to PQconnectdb #388
Conversation
Unfortunately all tests fail. Could you please fix this? |
This is always how I like to start my PRs...tells people I mean business ;) Let me try and fix this mess I made... |
Local tests pass 👍 I excluded the test that allowed the user to override |
As I recall, URI and Hash are accepted together so the caller can set/override parameters like Should the caller have to think differently about |
@@ -49,8 +49,7 @@ def self::parse_connect_args( *args ) | |||
if args.length == 1 | |||
case args.first | |||
when URI, /\A#{URI::ABS_URI_REF}\z/ | |||
uri = URI(args.first) | |||
options.merge!( Hash[URI.decode_www_form( uri.query )] ) if uri.query | |||
uri = args.first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to have uri
either always be URI
or always be String
. We don't use the structure of URI
later on, so converting to String
seems appropriate here.
uri = String(args.first)
if uri.is_a? URI | ||
uri = uri.to_s | ||
end | ||
if uri.include?("?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like ?
does not definitely indicate there is a query.
> URI('postgres://u?n:pw@localhost')
=> #<URI::Generic postgres://u?n:pw@localhost>
> URI('postgres://un:p?w@localhost')
Traceback (most recent call last):
URI::InvalidURIError (bad URI(is not URI?): "postgres://un:p?w@localhost")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is interesting...and unfortunate. At the same time, I can't parse the URI that may have two hosts or more because that's definitely not valid. Hmm.
I overhauled the connection string parser to support URIs with multiple hosts in 5e8c911 . It takes a tradeoff by not modifying the parts of the URI, that were given to the API call, but extends it with additional parameters like |
Fixes #387