Ecto query fragments for Tempo.Ecto.SQLite.TempoRange columns, named
after Allen's interval algebra as Tempo.Ecto.QueryAPI names the
PostgreSQL range operators.
import Ecto.Query
import Tempo.Ecto.SQLite.QueryAPI
{:ok, morning} = Tempo.Ecto.SQLite.QueryAPI.probe(~o"2026-06-15T09:00Z/2026-06-15T12:00Z")
from m in Meeting, where: overlaps(m.window, ^morning)The right-hand operand is a probe, the integer bounds of an expression
probe/2 makes on the column's frame, pinned with ^. Each macro
compares those bounds with the bounds the column's document holds:
overlaps/2— whether a span of the column shares any second with the probe.contains/2— whether a span of the column holds every second of the probe.meets/2— whether the column's stretch ends where the probe begins, or begins where it ends.strictly_before/2— whether the column's stretch ends at or before the probe begins: Allen'sprecedesandmeets.strictly_after/2— whether the column's stretch begins at or after the probe ends.
overlaps/2 and contains/2 test each span the column holds, so the
gaps between a set's members match nothing, and first compare the
stretch, which the indexes Tempo.SQL.SQLite.Migration.create_tempo_range_index/2
creates answer. The bounds are whole seconds.
Summary
Functions
Matches rows with a span that holds every second of the probe.
Matches rows whose stretch ends where the probe begins, or begins where it ends.
Matches rows with a span that shares any second with the probe.
Makes the probe a query compares a column with: the bounds of an expression, in whole seconds on the column's frame.
Matches rows whose stretch begins at or after the probe ends.
Matches rows whose stretch ends at or before the probe begins.
Types
Functions
Matches rows with a span that holds every second of the probe.
Arguments
columnis aTempo.Ecto.SQLite.TempoRangecolumn.probeis a probe fromprobe/2, pinned with^.
Returns
- A query fragment usable anywhere Ecto accepts a boolean expression.
Examples
from s in Shop, where: contains(s.opening_hours, ^half_past_nine)
Matches rows whose stretch ends where the probe begins, or begins where it ends.
Arguments
columnis aTempo.Ecto.SQLite.TempoRangecolumn.probeis a probe fromprobe/2, pinned with^.
Returns
- A query fragment usable anywhere Ecto accepts a boolean expression.
Examples
from m in Meeting, where: meets(m.window, ^lunch)
Matches rows with a span that shares any second with the probe.
Arguments
columnis aTempo.Ecto.SQLite.TempoRangecolumn.probeis a probe fromprobe/2, pinned with^.
Returns
- A query fragment usable anywhere Ecto accepts a boolean expression.
Examples
from m in Meeting, where: overlaps(m.window, ^morning)
@spec probe(Tempo.t(), Tempo.SQL.Conversion.frame()) :: {:ok, probe()} | {:error, Exception.t()}
Makes the probe a query compares a column with: the bounds of an expression, in whole seconds on the column's frame.
Arguments
expressionis aTempo.t/0with a place on the time line.frameis the column's frame,:utc(the default) or:floating.
Returns
{:ok, probe}, a map of:loand:hi, to pin with^.{:error, exception}for an expression with no place on the time line, or of the other frame.
Examples
iex> Tempo.Ecto.SQLite.QueryAPI.probe(~o"2026-06-15T09:00Z/2026-06-15T10:00Z")
{:ok, %{lo: 1781514000, hi: 1781517600}}
iex> {:error, error} = Tempo.Ecto.SQLite.QueryAPI.probe(~o"2026-06-15T09:00/2026-06-15T10:00")
iex> error.reason
:frame
Matches rows whose stretch begins at or after the probe ends.
Arguments
columnis aTempo.Ecto.SQLite.TempoRangecolumn.probeis a probe fromprobe/2, pinned with^.
Returns
- A query fragment usable anywhere Ecto accepts a boolean expression.
Examples
from m in Meeting, where: strictly_after(m.window, ^lunch)
Matches rows whose stretch ends at or before the probe begins.
Arguments
columnis aTempo.Ecto.SQLite.TempoRangecolumn.probeis a probe fromprobe/2, pinned with^.
Returns
- A query fragment usable anywhere Ecto accepts a boolean expression.
Examples
from m in Meeting, where: strictly_before(m.window, ^lunch)