# `AshPostgres.Ltree`
[🔗](https://github.com/ash-project/ash_postgres/blob/v2.9.1/lib/types/ltree.ex#L5)

Ash Type for [postgres `ltree`](https://www.postgresql.org/docs/current/ltree.html),
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 `m:AshPostgres.Repo#module-installed-extensions`

## Constraints

* `:escape?` (`t: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` (`t:non_neg_integer/0`) - A minimum length for the tree segments.

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

# `segment`

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

# `t`

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

# `handle_change?`

# `prepare_change?`

# `shared_root`

```elixir
@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"])
    []

---

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