Skip to content

Commit

Permalink
fix: allow host tuple (#1021)
Browse files Browse the repository at this point in the history
  • Loading branch information
lezram committed Oct 10, 2023
1 parent b2697ff commit d7faaff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion asyncpg/connect_utils.py
Expand Up @@ -403,7 +403,7 @@ def _parse_connect_dsn_and_args(*, dsn, host, port, user,
host = ['/run/postgresql', '/var/run/postgresql',
'/tmp', '/private/tmp', 'localhost']

if not isinstance(host, list):
if not isinstance(host, (list, tuple)):
host = [host]

if auth_hosts is None:
Expand Down
13 changes: 13 additions & 0 deletions tests/test_connect.py
Expand Up @@ -671,6 +671,19 @@ class TestConnectParams(tb.TestCase):
'target_session_attrs': 'any',
})
},
{
'name': 'params_multi_host_dsn_env_mix_tuple',
'env': {
'PGUSER': 'foo',
},
'dsn': 'postgresql:///db',
'host': ('host1', 'host2'),
'result': ([('host1', 5432), ('host2', 5432)], {
'database': 'db',
'user': 'foo',
'target_session_attrs': 'any',
})
},

{
'name': 'params_combine_dsn_settings_override_and_ssl',
Expand Down

0 comments on commit d7faaff

Please sign in to comment.