Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

RLS seems unable to handle multiple references to the same table. #195

@justinanderson

Description

@justinanderson

Given the RLS rule:

grant select access to foo on asdf._file_with_spaces where pay_basis = 'ANN'

And the query:

SELECT * from asdf._file_with_spaces where agency in (SELECT distinct(agency) as _file_with_spaces from asdf._file_with_spaces where agency like 'Department%' order by agency)

The result after an RLS rewrite is:

SELECT * from (
    SELECT * FROM asdf._file_with_spaces WHERE pay_basis = 'ANN')
AS asdf_file_with_spaces where agency in (
    SELECT distinct(agency) as _file_with_spaces from (
        SELECT * FROM asdf_file_with_spaces WHERE pay_basis = 'ANN')
    AS asdf_file_with_spaces where agency like 'Department%' order by agency)

The third occurence of asdf_file_with_spaces is a problem, since it doesn't exist at that point. This query results in a 404 since the table can't be found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions