Skip to main content

reference_visible

Function reference_visible 

Source
pub async fn reference_visible(
    pool: &PgPool,
    caller_table: &str,
    table: &str,
    column: &str,
    value: &Value,
) -> Result<Option<bool>>
Expand description

Whether the row of table whose column holds value is visible on the caller’s scope: one SELECT EXISTS run as every read is (on the request’s connection when one is bound, else under the task’s company scope), so a row row-level security hides reads as absent. Postgres checks a foreign key without row-level security; this is the check that does not.

value is a JSON scalar, cast to the column’s own type by jsonb_populate_record, so the lookup keeps the column’s index whatever its type. table and column are generator-emitted (PersistentEntity::references), never client input, and are refused unless they are plain identifiers. A bare table resolves as fetch_by_ids_as_json’s does: the caller’s schema first, then the search path. Ok(None) when the table does not exist in either spelling (its module is not installed, and the database has no key to it either).