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

Post.parent() gives wrong query. #4

Open
VandorpeDavid opened this issue Jul 16, 2018 · 0 comments
Open

Post.parent() gives wrong query. #4

VandorpeDavid opened this issue Jul 16, 2018 · 0 comments

Comments

@VandorpeDavid
Copy link

VandorpeDavid commented Jul 16, 2018

post |> Post.parent() |> Repo.one()

results in

** (Ecto.Query.CastError) deps/ecto_materialized_path/lib/ecto_materialized_path.ex:73: value 4 in where cannot be cast to type {:in, :id} in query:

from a in Post
where: a.id in ^4,
limit: 1,
select: a

(elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
(elixir) lib/enum.ex:1397: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
(ecto) lib/ecto/repo/queryable.ex:124: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:37: Ecto.Repo.Queryable.all/4
(ecto) lib/ecto/repo/queryable.ex:70: Ecto.Repo.Queryable.one/4
(stdlib) erl_eval.erl:677: :erl_eval.do_apply/6
(iex) lib/iex/evaluator.ex:250: IEx.Evaluator.handle_eval/5
(iex) lib/iex/evaluator.ex:230: IEx.Evaluator.do_eval/3
(iex) lib/iex/evaluator.ex:208: IEx.Evaluator.eval/3

Running post |> Post.parent() returns

#Ecto.Query<from a in Post, where: a.id in ^4, limit: 1>

The use of the in operator seems weird to me, but it has been there for over a year, and noone has complained yet. This makes me wonder if I am doing something wrong.

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

1 participant