Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with $in clause? #133

Open
gottfrois opened this issue Jul 18, 2017 · 2 comments
Open

Issue with $in clause? #133

gottfrois opened this issue Jul 18, 2017 · 2 comments

Comments

@gottfrois
Copy link

I'm trying to perform a where clause with a $in but without success:

Hookshot.Hook.with_events([1, 2]) |> Hookshot.Repo.all
** (Ecto.Query.CastError) web/models/hook.ex:63: value `[1, 2]` in `where` cannot be cast to type {:in, {:array, :string}} in query:

from h in Hookshot.Hook,
  where: h.events in ^[1, 2],
  select: h

    (elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
    (elixir) lib/enum.ex:1325: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
      (ecto) lib/ecto/repo/queryable.ex:122: Ecto.Repo.Queryable.execute/5
      (ecto) lib/ecto/repo/queryable.ex:35: Ecto.Repo.Queryable.all/4
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
       (iex) lib/iex/evaluator.ex:182: IEx.Evaluator.handle_eval/6
       (iex) lib/iex/evaluator.ex:175: IEx.Evaluator.do_eval/4
       (iex) lib/iex/evaluator.ex:155: IEx.Evaluator.eval/4

Am I doing something wrong?

I'm using:

{:mongodb_ecto, github: "michalmuskala/mongodb_ecto", branch: "ecto-2.1"},
@michalmuskala
Copy link
Collaborator

Ecto 2.1 changed representation query generator receives on in queries to better support SQL caching. It seems the 2.1 branch was not updated.

@ankhers
Copy link
Collaborator

ankhers commented Nov 27, 2017

Is this still an issue on the ecto-2.1 branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants