Lotus.Preflight.Relations (Lotus v1.1.0)

Copy Markdown View Source

The preflight outcome: what Lotus knows about the relations a statement touches.

The outcome is one of:

  • a list of {schema, table} relations preflight proved the statement touches — an empty list means it touches none;
  • {:unrestricted, reason} for an adapter that cannot name the relations a statement touches, when the host opted in;
  • {:skipped, reason} for a statement the adapter does not preflight.

The two tuples both mean "unknown". A consumer that gates on the list matches when is_list/1 and refuses any tuple rather than reading it as an empty set.

Lotus.Preflight.analyze/4 returns the outcome as a value, and Lotus.Runner carries it down the pipeline explicitly. The process dictionary functions below are kept for callers that still store an outcome themselves; the runner neither writes nor reads them.

Summary

Functions

Clears the stored preflight outcome.

Retrieves the stored preflight outcome, or an empty list.

Stores a preflight outcome in the process dictionary.

Retrieves and clears the stored preflight outcome.

Narrows a preflight outcome to the list of relations it names.

Types

outcome()

@type outcome() :: [relation()] | {:unrestricted, String.t()} | {:skipped, String.t()}

relation()

@type relation() :: {String.t() | nil, String.t()}

Functions

clear()

@spec clear() :: :ok

Clears the stored preflight outcome.

get()

@spec get() :: outcome()

Retrieves the stored preflight outcome, or an empty list.

put(relations)

@spec put(outcome()) :: :ok

Stores a preflight outcome in the process dictionary.

take()

@spec take() :: outcome()

Retrieves and clears the stored preflight outcome.

to_list(relations)

@spec to_list(outcome()) :: [relation()]

Narrows a preflight outcome to the list of relations it names.

An unknown outcome names none, so it narrows to []. Column visibility policies use this: a relation Lotus cannot name is a relation it cannot write a policy for.