Query helpers used by the EEx templates in priv/templates/ecto_context/.
These functions are called at runtime from code generated by EctoContext.
They handle optional query composition — preloading, ordering, limiting,
selecting, and filtering by association.
Summary
Functions
Filters a query by the foreign key of the given association.
Conditionally applies a limit clause. No-op when nil.
Conditionally applies an order_by clause. No-op when nil.
Conditionally preloads associations. No-op when nil.
Conditionally applies a 1-arity query function. No-op when nil.
Conditionally applies a select clause. No-op when nil.
Resolves the foreign key field for an association.
Functions
@spec assoc_where(Ecto.Queryable.t(), module(), atom(), term()) :: Ecto.Query.t()
Filters a query by the foreign key of the given association.
Resolves the foreign key via resolve_foreign_key/2, then applies a where clause.
@spec maybe_limit(Ecto.Queryable.t(), nil | pos_integer()) :: Ecto.Query.t()
Conditionally applies a limit clause. No-op when nil.
@spec maybe_order_by(Ecto.Queryable.t(), nil | term()) :: Ecto.Query.t()
Conditionally applies an order_by clause. No-op when nil.
@spec maybe_preload(Ecto.Queryable.t(), nil | term()) :: Ecto.Query.t()
Conditionally preloads associations. No-op when nil.
@spec maybe_query( Ecto.Queryable.t(), nil | (Ecto.Queryable.t() -> Ecto.Queryable.t()) ) :: Ecto.Queryable.t()
Conditionally applies a 1-arity query function. No-op when nil.
@spec maybe_select(Ecto.Queryable.t(), nil | [atom()]) :: Ecto.Query.t()
Conditionally applies a select clause. No-op when nil.
Resolves the foreign key field for an association.
Tries Ecto schema reflection first, falls back to :assoc_id convention.
This allows list_for to work with both regular belongs_to and static_belongs_to.