I created a Postgrex Ltree extension https://hexdocs.pm/postgrex/Postgrex.Extension.html.
These queries work:
Repo.all from n in Node, where: fragment("path <@ ?", "1")
var = "1"
Repo.all from n in Node, where: fragment("path <@ ?", ^var)
Repo.all from n in Node, where: fragment("path <@ ?::ltree[]", ["1", "2"])
And this query doesn’t:
vars = ["1", "2"]
Repo.all from n in Node, where: fragment("path <@ ?::ltree[]", ^vars)
[error] Postgrex.Protocol (#PID<0.289.0>) disconnected: ** (RuntimeError) type `_ltree` can not be handled by the types module MyApp.PostgresTypes
** (RuntimeError) type `_ltree` can not be handled by the types module MyApp.PostgresTypes
(ecto) lib/ecto/adapters/postgres/connection.ex:79: Ecto.Adapters.Postgres.Connection.prepare_execute/5
(ecto) lib/ecto/adapters/sql.ex:256: Ecto.Adapters.SQL.sql_call/6
(ecto) lib/ecto/adapters/sql.ex:426: Ecto.Adapters.SQL.execute_and_cache/7
(ecto) lib/ecto/repo/queryable.ex:133: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:37: Ecto.Repo.Queryable.all/4
Elixir 1.5.1
Ecto 2.2.5
Postgrex 0.13.3