Skip to content

Commit 2fff2e9

Browse files
[MISC] Extend relation-user listing syntax (#957)
1 parent 083b303 commit 2fff2e9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/charms/postgresql_k8s/v0/postgresql.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
# Increment this PATCH version before using `charmcraft publish-lib` or reset
3737
# to 0 if you are raising the major API version
38-
LIBPATCH = 51
38+
LIBPATCH = 53
3939

4040
# Groups to distinguish HBA access
4141
ACCESS_GROUP_IDENTITY = "identity_access"
@@ -672,7 +672,9 @@ def list_users_from_relation(self) -> Set[str]:
672672
try:
673673
with self._connect_to_database() as connection, connection.cursor() as cursor:
674674
cursor.execute(
675-
"SELECT usename FROM pg_catalog.pg_user WHERE usename LIKE 'relation_id_%';"
675+
"SELECT usename "
676+
"FROM pg_catalog.pg_user "
677+
"WHERE usename LIKE 'relation_id_%' OR usename LIKE 'relation-%';"
676678
)
677679
usernames = cursor.fetchall()
678680
return {username[0] for username in usernames}

tests/unit/test_postgresql.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ def test_grant_relation_access_group_memberships(harness):
208208
harness.charm.postgresql.grant_relation_access_group_memberships()
209209

210210
execute.assert_has_calls([
211-
call("SELECT usename FROM pg_catalog.pg_user WHERE usename LIKE 'relation_id_%';"),
211+
call(
212+
"SELECT usename "
213+
"FROM pg_catalog.pg_user "
214+
"WHERE usename LIKE 'relation_id_%' OR usename LIKE 'relation-%';"
215+
),
212216
])
213217

214218

0 commit comments

Comments
 (0)