EctoRange.Int4 (ecto_range v0.3.0)

View Source

A Postgres range of int4 integers. Equivalent to int4range.

Summary

Functions

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.

Converts a Postgrex.Range.t() into a normalized form. For bounded ranges, it will make the lower and upper bounds inclusive.

Checks and converts a Postgrex.Range or tuple into a Postgrex.Range.t()

Functions

embed_as(_)

Callback implementation for Ecto.Type.embed_as/1.

equal?(term1, term2)

Callback implementation for Ecto.Type.equal?/2.

normalize_range(range)

Converts a Postgrex.Range.t() into a normalized form. For bounded ranges, it will make the lower and upper bounds inclusive.

Examples

iex> range = %Postgrex.Range{lower: 1, upper: 3, lower_inclusive: true, upper_inclusive: false}
iex> EctoRange.Int4.normalize_range(range)
%Postgrex.Range{lower: 1, upper: 2, lower_inclusive: true, upper_inclusive: true}

iex> range = %Postgrex.Range{lower: 1, upper: 3, lower_inclusive: false, upper_inclusive: true}
iex> EctoRange.Int4.normalize_range(range)
%Postgrex.Range{lower: 2, upper: 3, lower_inclusive: true, upper_inclusive: true}

to_postgrex_range(range)

@spec to_postgrex_range(Postgrex.Range.t() | {integer(), integer()}) ::
  Postgrex.Range.t()

Checks and converts a Postgrex.Range or tuple into a Postgrex.Range.t()

Examples

iex> EctoRange.Int4.to_postgrex_range({1, 3})
%Postgrex.Range{lower: 1, upper: 3, lower_inclusive: true, upper_inclusive: true}