refactor password assignment logic

This commit is contained in:
Divyansh Singh 2023-06-15 22:54:06 +05:30
parent a9386b7a87
commit b7423c488e
2 changed files with 5 additions and 2 deletions

View file

@ -30,7 +30,10 @@ def make_extra_environment(database, restore_connection_params=None):
extra = dict()
try:
extra['PGPASSWORD'] = restore_connection_params.get('password') or database['restore_password'] or database['password']
if restore_connection_params:
extra['PGPASSWORD'] = restore_connection_params.get('password') or database.get('restore_password', database['password'])
else:
extra['PGPASSWORD'] = database['password']
except (AttributeError, KeyError):
pass