Skip to content

DEV: Patch ActiveRecord's postgresql adapter .new_client #33820

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tgxworld
Copy link
Contributor

This commit updates our monkey patch of
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.new_client to
improve two things:

  1. Improve the conditional used to determine if a database does not
    exist. Just checking that the error message contains the database
    name is not sufficient as the value of the database name may be part of
    the host connection param which can appear in PG error messages as
    well.

  2. When the PG error messages includes the user or host connection
    param. We append the original PG error message on to the original
    error messge so that we don't just end up with a generic error message
    that doesn't help us to figure out the actual error.

This commit updates our monkey patch of
`ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.new_client` to
improve two things:

1. Improve the conditional used to determine if a database does not
   exist. Just checking that the error message contains the `database`
name is not sufficient as the value of the database name may be part of
the `host` connection param which can appear in PG error messages as
well.

2. When the PG error messages includes the `user` or `host` connection
   param. We append the original PG error message on to the original
error messge so that we don't just end up with a generic error message
that doesn't help us to figure out the actual error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant