# `Localize.Ecto.Type.IntegerRange`
[🔗](https://github.com/elixir-localize/localize_sql/blob/v1.0.1/lib/localize/ecto/type/integer_range.ex#L2)

An `Ecto.Type` storing an Elixir integer `t:Range.t/0` in a PostgreSQL
`int8range` column.

A range such as `1..10` stores and loads as itself, so a bounded span
of integers is a first-class value in a schema rather than a pair of
columns. `int8range` is a built-in PostgreSQL type, so no migration
beyond the column is needed, and the column can be queried with the
range operators (`@>`, `&&`) and indexed with a GiST index.

### Schema

    # in a migration
    add :levels, :int8range

    # in a schema
    field :levels, Localize.Ecto.Type.IntegerRange

### Semantics

Elixir ranges are inclusive of both ends, so `1..10` covers `1`
through `10`; it is stored as the PostgreSQL range `[1,10]` and read
back as `1..10` regardless of the bound form PostgreSQL canonicalizes
to (it stores `int8range` as `[lower, upper)`).

Only ascending unit-step ranges are storable — a range carrying a
step (`1..10//2`) or descending (an empty range like `10..1//1`) has
no `int8range` equivalent and is rejected on cast and dump.

# `embed_as`

# `equal?`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
