Home > Back-end >  Error trying to execute query in Elixir with Ecto
Error trying to execute query in Elixir with Ecto

Time:04-05

I have an Elixir app that uses Ecto in order to execute queries in Postgres. I have this Ecto schema:

defmodule Person do

  use Ecto.Schema

  schema "person" do
    field :name, :string
  end

end

I'm trying to make a simple select in Elixir:

query = from Person
result = Repo.all(query)

but after executing that code, I see this:

** (FunctionClauseError) no function clause matching in Ecto.Adapters.Postgres.Connection.expr/3

The following arguments were given to Ecto.Adapters.Postgres.Connection.expr/3:

    # 1
    {{:., [], [{:&, [], [0]}, "name"]}, [], []}

    # 2
    {{[34, "Person", 34], [84 | "0"],
      Person}, []}

    # 3
    #Ecto.Query<from c0 in Person,
     select: c0>

Attempted function clauses (showing 10 out of 33):

    defp expr(-{:^, [], [ix]}-, _sources, _query)
    defp expr(-{{:., _, [{:parent_as, _, [as]}, field]}, _, []}-, _sources, query) when -is_atom(field)-
    defp expr({{:., _, [{:&, _, [idx]}, field]}, _, []}, sources, _query) when -is_atom(field)-
    defp expr(-{:&, _, [idx]}-, sources, _query)
    defp expr(-{:in, _, [_left, []]}-, _sources, _query)
    defp expr(-{:in, _, [left, right]}-, sources, query) when -is_list(right)-
    defp expr(-{:in, _, [left, {:^, _, [ix, _]}]}-, sources, query)
    defp expr(-{:in, _, [left,            
  • Related