Allow blank DB host value, reuse backend code #15736
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
This avoids us create a "connection string" which was already believed to be brittle and undesirable.
Here are some research links of various value:
https://github.com/django/django/blob/main/django/db/backends/base/base.py#L30
https://github.com/django/django/blob/main/django/db/backends/postgresql/base.py
This create the same thing as
django.db.connection
, but using that object specifically comes with a lot of baggage. It's much cleaner to just create it, as what we need is set up in its__init__
. This avoids touching the already active connection, which is being used for other stuff. Thedeepcopy
we already had still seems like a good idea.The idea is that
"HOST"
in the DATABASES setting may be an empty string. Instead of handling this specifically, I'm trying to do it the "right" way finally here. Presumably this works for password-less auth which we were already trying to allow.Essentially, we have to "translate" the Django database settings into the psycopg parameters, and instead of doing it manually we will use the logic already written in Django.
ISSUE TYPE
COMPONENT NAME