Mutare.Ecto.QueryTerminal (mutare_ecto v0.1.1)

Copy Markdown View Source

Swap Ecto.Query.first/1,2Ecto.Query.last/1,2 — the query "terminals" that restrict a query to a single edge of its ordering. first keeps the first row by the order (primary key ascending when none is given); last reverses it. Swapping them is a clean, same-arity rename (so it always compiles), behaviour-changing whenever the query can return more than one row — a survivor means no test pins which end the query is taking.

These are plain Ecto.Query functions (not the macro DSL), so they resolve through Mutare.Calls.resolved_call_to/3 in every written form — qualified (Ecto.Query.first(q)), aliased, or bare under import Ecto.Query — and ride Mutare's ordinary in-place selector. The rebuild keeps the source's written form (and is pipe-agnostic: q |> first() has an empty arg list, so q |> last() falls out for free). Family :query_terminal.

Summary

Functions

First↔last swap for an Ecto.Query terminal call as a :query_terminal tag, or [].

Functions

mutations(node, context)

@spec mutations(Macro.t(), Mutare.Ecto.Context.t()) :: [Mutare.Ecto.Tag.t()]

First↔last swap for an Ecto.Query terminal call as a :query_terminal tag, or [].