diff --git a/asyncpg/connect_utils.py b/asyncpg/connect_utils.py index e215391b..f02e3ab7 100644 --- a/asyncpg/connect_utils.py +++ b/asyncpg/connect_utils.py @@ -850,7 +850,7 @@ def _parse_connect_dsn_and_args(*, dsn, host, port, user, "target_session_attrs is expected to be one of " "{!r}" ", got {!r}".format( - SessionAttribute.__members__.values, target_session_attrs + [a.value for a in SessionAttribute], target_session_attrs ) ) from None diff --git a/tests/test_connect.py b/tests/test_connect.py index 1c25d8d6..3bc4bb82 100644 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -751,6 +751,17 @@ class TestConnectParams(tb.TestCase): }) }, + { + 'name': 'target_session_attrs_invalid', + 'dsn': 'postgresql://user@host/db?target_session_attrs=bogus', + 'error': ( + exceptions.ClientConfigurationError, + r"target_session_attrs is expected to be one of " + r"\['any', 'primary', 'standby', 'prefer-standby', " + r"'read-write', 'read-only'\], got 'bogus'" + ), + }, + { 'name': 'krbsrvname', 'dsn': 'postgresql://user@host/db?krbsrvname=srv_qs',