Skip to content
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

PostgreSQL adapter uses :host instead of :hostname for connection params #47715

Merged
merged 1 commit into from
Mar 20, 2023

Conversation

adrianna-chang-shopify
Copy link
Contributor

Motivation / Background

I noticed that the error translation code for the PG adapter looks for a :hostname arg in the conn_params in order to translate to a hostname error. However, the PostgreSQL docs specify that either host or hostaddr should be used, so I'm inclined to think this is an error.

irb(main):001:0> require "pg"
=> true
irb(main):002:0> PG.connect(hostname: "localhost")
/Users/adriannachang/.gem/ruby/3.1.1/gems/pg-1.4.5/lib/pg/connection.rb:714:in `conninfo_parse': invalid connection option "hostname" (PG::Error)
        from /Users/adriannachang/.gem/ruby/3.1.1/gems/pg-1.4.5/lib/pg/connection.rb:714:in `connect_to_hosts'   
        from /Users/adriannachang/.gem/ruby/3.1.1/gems/pg-1.4.5/lib/pg/connection.rb:695:in `new'                
        from /Users/adriannachang/.gem/ruby/3.1.1/gems/pg-1.4.5/lib/pg.rb:69:in `connect'                        
        from (irb):2:in `<main>'                                                                                 
        from /Users/adriannachang/.gem/ruby/3.1.1/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'                
        from /Users/adriannachang/.gem/ruby/3.1.1/bin/irb:25:in `load'                                           
        from /Users/adriannachang/.gem/ruby/3.1.1/bin/irb:25:in `<main>'

Detail

Use :host from connection params instead of :hostname for translating hostname errors in PostgreSQL adapter.

Additional information

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature. (If this warrants a test, I'm happy to add one)
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@matthewd matthewd merged commit bc081a5 into rails:main Mar 20, 2023
@adrianna-chang-shopify adrianna-chang-shopify deleted the ac-pg-fix-conn-param branch March 20, 2023 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants