View Source AshPostgres.Ltree (ash_postgres v2.4.5)

Ash Type for postgres ltree, a hierarchical tree-like data type.

Postgres Extension

To be able to use the ltree type, you'll have to enable the postgres ltree extension first.

See AshPostgres.Repo

Constraints

  • :escape? (boolean/0) - Escape the ltree segments to make it possible to include characters that are either . (the separation character) or any other unsupported character like - (Postgres <= 15).

    If the option is enabled, any characters besides [0-9a-zA-Z] will be replaced with _[HEX Ascii Code].

    Additionally the type will no longer take strings as user input since it's impossible to decide between . being a separator or part of a segment.

    If the option is disabled, any string will be relayed directly to postgres. If the segments are provided as a list, they can't contain . since postgres would split the segment.

  • :min_length (non_neg_integer/0) - A minimum length for the tree segments.

  • :max_length (non_neg_integer/0) - A maximum length for the tree segments.

Summary

Functions

Get shared root of given ltrees.

Types

segment()

@type segment() :: String.t()

t()

@type t() :: [segment()]

Functions

shared_root(ltree1, ltree2)

@spec shared_root(ltree1 :: t(), ltree2 :: t()) :: t()

Get shared root of given ltrees.

Examples

iex> Ltree.shared_root(["1", "2"], ["1", "1"])
["1"]

iex> Ltree.shared_root(["1", "2"], ["2", "1"])
[]