EctoQueryParser.Builder (EctoQueryParser v0.5.0)

Copy Markdown View Source

Converts parsed AST nodes into Ecto dynamic expressions.

Summary

Functions

Builds an Ecto dynamic expression from a parsed AST.

Functions

build(ast, opts \\ [])

Builds an Ecto dynamic expression from a parsed AST.

Options

  • :allowed_fields - list of atom field names that are permitted. If provided, any field not in the list will return an error.
  • :schema - the Ecto schema module, needed to resolve dotted identifiers (association paths like author.name).
  • :params - map of {{name}} parameter bindings (%{"name" => value}). Optional groups whose parameters are unbound are pruned; any remaining unbound parameter is a build error.
  • :literal_transform - fun(ecto_type, raw_string) called for string literals (and bound string parameter values) compared against a typed field, before the built-in coercion. May return {:ok, term} (replace the value; the transform owns the type), {:range, {lo, hi}} (the literal denotes an inclusive range; only meaningful for comparison and BETWEEN operators), or :default (fall through to normal coercion).

Returns {:ok, dynamic, joins} or {:error, reason}.