AshOnetime.Boundary.Query (ash_onetime v1.9.2)

Copy Markdown View Source

The context-boundary query expression and its validation.

A query is a boolean expression over tags and types — {:tag, t}, {:type, t}, {:any, [branch]}, {:all, [branch]}, {:not, inner} — with branches as lists of expressions. Validation enforces the package's size bounds and tag-anchoring: every fact the query can match carries at least one tag the query names, which is what makes AshOnetime.Boundary.append_if/5's advisory-lock set cover the context (any concurrent writer whose fact matches must lock one of those tags). A query naming no tag — or whose matches could be satisfied by a type branch or a negation alone — is refused.

Summary

Functions

Compiles the validated expression into a parameterized SQL predicate.

Types

expr()

@type expr() ::
  {:tag, leaf()}
  | {:type, leaf()}
  | {:any, [expr()]}
  | {:all, [expr()]}
  | {:not, expr()}

leaf()

@type leaf() :: binary()

t()

@type t() :: %AshOnetime.Boundary.Query{expr: expr(), tags: [binary()]}

Functions

predicate(query, start)

@spec predicate(t(), pos_integer()) :: {binary(), [binary()]}

Compiles the validated expression into a parameterized SQL predicate.

start is the 1-based index of the first parameter the predicate may claim; returns the fragment and its parameter list.

validate(input)

@spec validate(term()) :: {:ok, t()} | {:error, String.t()}