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
6 changes: 4 additions & 2 deletions lib/charms/postgresql_k8s/v0/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/test_postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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-%';"
),
])


Expand Down