Refs #32292 -- Made dbshell do not use 'postgres' database when service name is set.
Regression in dcb3ad3319
.
This commit is contained in:
parent
9d7e31cc74
commit
8908846444
|
@ -13,7 +13,7 @@ class DatabaseClient(BaseDatabaseClient):
|
||||||
|
|
||||||
host = settings_dict.get('HOST')
|
host = settings_dict.get('HOST')
|
||||||
port = settings_dict.get('PORT')
|
port = settings_dict.get('PORT')
|
||||||
dbname = settings_dict.get('NAME') or 'postgres'
|
dbname = settings_dict.get('NAME')
|
||||||
user = settings_dict.get('USER')
|
user = settings_dict.get('USER')
|
||||||
passwd = settings_dict.get('PASSWORD')
|
passwd = settings_dict.get('PASSWORD')
|
||||||
service = options.get('service')
|
service = options.get('service')
|
||||||
|
@ -22,13 +22,17 @@ class DatabaseClient(BaseDatabaseClient):
|
||||||
sslcert = options.get('sslcert')
|
sslcert = options.get('sslcert')
|
||||||
sslkey = options.get('sslkey')
|
sslkey = options.get('sslkey')
|
||||||
|
|
||||||
|
if not dbname and not service:
|
||||||
|
# Connect to the default 'postgres' db.
|
||||||
|
dbname = 'postgres'
|
||||||
if user:
|
if user:
|
||||||
args += ['-U', user]
|
args += ['-U', user]
|
||||||
if host:
|
if host:
|
||||||
args += ['-h', host]
|
args += ['-h', host]
|
||||||
if port:
|
if port:
|
||||||
args += ['-p', str(port)]
|
args += ['-p', str(port)]
|
||||||
args += [dbname]
|
if dbname:
|
||||||
|
args += [dbname]
|
||||||
args.extend(parameters)
|
args.extend(parameters)
|
||||||
|
|
||||||
env = {}
|
env = {}
|
||||||
|
|
|
@ -70,7 +70,7 @@ class PostgreSqlDbshellCommandTestCase(SimpleTestCase):
|
||||||
def test_service(self):
|
def test_service(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.settings_to_cmd_args_env({'OPTIONS': {'service': 'django_test'}}),
|
self.settings_to_cmd_args_env({'OPTIONS': {'service': 'django_test'}}),
|
||||||
(['psql', 'postgres'], {'PGSERVICE': 'django_test'}),
|
(['psql'], {'PGSERVICE': 'django_test'}),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_column(self):
|
def test_column(self):
|
||||||
|
|
Loading…
Reference in New Issue