fix: workspaces query to correctly user username from users table (#15305)

The subquery on the users table was incorrectly using the username from
the `workspaces` table, not the `users` table.

This passed `sqlc-vet` because the column did exist in the query, it
just was not the correct one.
This commit is contained in:
Steven Masley
2024-10-31 12:33:07 -04:00
committed by GitHub
parent 4849b4d8ac
commit 9d03e0429f
3 changed files with 35 additions and 2 deletions

View File

@ -233,7 +233,7 @@ WHERE
-- Filter by owner_name
AND CASE
WHEN @owner_username :: text != '' THEN
workspaces.owner_id = (SELECT id FROM users WHERE lower(owner_username) = lower(@owner_username) AND deleted = false)
workspaces.owner_id = (SELECT id FROM users WHERE lower(users.username) = lower(@owner_username) AND deleted = false)
ELSE true
END
-- Filter by template_name