Sifter.Ecto.Builder (Sifter v0.2.0)

View Source

The Builder transforms parsed Sifter.AST nodes into Ecto query expressions.

This module serves as the bridge between Sifter's abstract syntax tree representation and Ecto's query DSL, generating dynamic SQL fragments that can be applied to Ecto queries. The Builder handles field validation, type casting, association joins, and full-text search strategies while providing comprehensive metadata about the generated query.

Summary

Types

meta()

@type meta() :: %{
  uses_full_text?: boolean(),
  added_select_fields: [atom()],
  recommended_order: [{atom(), :asc | :desc}] | nil,
  warnings: [map()] | nil
}

Functions

apply(queryable, ast, opts)

@spec apply(Ecto.Queryable.t(), Sifter.AST.t(), keyword()) ::
  {:ok, Ecto.Query.t(), meta()}
  | {:ok, :no_predicates, Ecto.Query.t()}
  | {:error, {:builder, term()}}