Fix owner deletion by qualifying ambiguous tenant_id column

The CountActiveOwnerByOrganizationID query joins iam_membership_profiles with
iam_memberships, but used an unqualified tenant_id = @tenant_id in the WHERE
clause. Since both tables have a tenant_id column, PostgreSQL raised an
"ambiguous column" error when deleting an owner. Fixed by prefixing with the
table alias (p.tenant_id) to match the pattern used in CountByOrganizationID.

Added TestUser_RemoveOwner e2e test to verify one owner can remove another.

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-19 11:53:07 +01:00
parent 922c0c2db8
commit d6b9280038
2 changed files with 89 additions and 1 deletions

View File

@@ -1121,7 +1121,7 @@ FROM
iam_membership_profiles p
INNER JOIN iam_memberships m ON m.identity_id = p.identity_id AND m.organization_id = p.organization_id
WHERE
%s
p.%s
AND p.organization_id = @organization_id
AND p.state = @state
AND m.role = @role