diff --git a/lib/charms/postgresql_k8s/v0/postgresql.py b/lib/charms/postgresql_k8s/v0/postgresql.py index 7e6a9d7631..f2ceea76bb 100644 --- a/lib/charms/postgresql_k8s/v0/postgresql.py +++ b/lib/charms/postgresql_k8s/v0/postgresql.py @@ -35,7 +35,7 @@ # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 51 +LIBPATCH = 53 # Groups to distinguish HBA access ACCESS_GROUP_IDENTITY = "identity_access" @@ -672,7 +672,9 @@ def list_users_from_relation(self) -> Set[str]: try: with self._connect_to_database() as connection, connection.cursor() as cursor: cursor.execute( - "SELECT usename FROM pg_catalog.pg_user WHERE usename LIKE 'relation_id_%';" + "SELECT usename " + "FROM pg_catalog.pg_user " + "WHERE usename LIKE 'relation_id_%' OR usename LIKE 'relation-%';" ) usernames = cursor.fetchall() return {username[0] for username in usernames} diff --git a/tests/unit/test_postgresql.py b/tests/unit/test_postgresql.py index 24e863b57b..ebce918853 100644 --- a/tests/unit/test_postgresql.py +++ b/tests/unit/test_postgresql.py @@ -208,7 +208,11 @@ def test_grant_relation_access_group_memberships(harness): harness.charm.postgresql.grant_relation_access_group_memberships() execute.assert_has_calls([ - call("SELECT usename FROM pg_catalog.pg_user WHERE usename LIKE 'relation_id_%';"), + call( + "SELECT usename " + "FROM pg_catalog.pg_user " + "WHERE usename LIKE 'relation_id_%' OR usename LIKE 'relation-%';" + ), ])