Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions asyncpg/connect_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,13 @@ def _parse_hostlist(hostlist, port):
port = _validate_port_spec(hostspecs, port)

for i, hostspec in enumerate(hostspecs):
addr, _, hostspec_port = hostspec.partition(':')
hosts.append(addr)
if not hostspec.startswith('/'):
addr, _, hostspec_port = hostspec.partition(':')
else:
addr = hostspec
hostspec_port = ''

hosts.append(addr)
if not port:
if hostspec_port:
hostlist_ports.append(int(hostspec_port))
Expand Down
30 changes: 30 additions & 0 deletions tests/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,36 @@ class TestConnectParams(tb.TestCase):
}
)
},
{
'dsn': 'postgres:///db?host=/cloudsql/'
'project:region:instance-name&user=spam',
'result': (
[os.path.join(
'/cloudsql/project:region:instance-name',
'.s.PGSQL.5432'
)], {
'user': 'spam',
'database': 'db'
}
)
},
{
'dsn': 'postgres:///db?host=127.0.0.1:5432,/cloudsql/'
'project:region:instance-name,localhost:5433&user=spam',
'result': (
[
('127.0.0.1', 5432),
os.path.join(
'/cloudsql/project:region:instance-name',
'.s.PGSQL.5432'
),
('localhost', 5433)
], {
'user': 'spam',
'database': 'db'
}
)
},
]

@contextlib.contextmanager
Expand Down