SELECT
    permission_type as "permission_type: PermissionRaw"
FROM
    permissions
WHERE
    folder_id = $1
    AND user_id = $2
UNION
SELECT
    'manage' as "permission_type: PermissionRaw"
FROM
    folders
WHERE
    folder_id = $1
    AND owner_id = $2