Tempo.Ecto.IntervalSet (Tempo SQL v0.1.0)

View Source

Ecto.ParameterizedType for persisting a Tempo.IntervalSet.t/0 as a PostgreSQL tstzmultirange value (PostgreSQL 14+).

Usage

schema "alice_calendar" do
  field :busy_times, Tempo.Ecto.IntervalSet
end

and in the migration:

add :busy_times, :tstzmultirange

(or use Tempo.SQL.Migration.add_interval_set/2).

Options

  • :resolution — on load, truncate every member interval's endpoints to the given component. Same values and semantics as Tempo.Ecto.Interval.

Storage contract

Every member interval must satisfy the same contract as Tempo.Ecto.Interval. In addition:

  • The set must be non-empty. An empty multirange round-trips as '{}'::tstzmultirange; use a NULL column to represent "no set".

  • Every member must be bounded on both ends (Tempo's IntervalSet.new/2 already enforces this).

Summary

Functions

cast_type(options \\ [])

See Tempo.Ecto.Interval.cast_type/1.