annkissam/rummage_ecto

search_type: :eq

zeuslocker opened this issue · 0 comments

Hello, is it lib related issue? If not what I'm doing wrong?
Thanks a lot.

pry(20)> args = %{search: %{age: %{search_term: 21, search_type: :eq}}}       
%{search: %{age: %{search_term: 21, search_type: :eq}}}
pry(21)> {queryable, _} = Rummage.Ecto.rummage(User, args, repo: Repo) 
{#Ecto.Query<from u in subquery(from u in ActSelect.Accounts.User),
  where: u.age == ^21>,
 %{
   search: %{
     age: %{assoc: [], search_expr: :where, search_term: 21, search_type: :eq}
   }
 }}
pry(22)> ActSelect.Repo.all(queryable)                                 
** (Ecto.QueryError) deps/rummage_ecto/lib/rummage_ecto/services/build_search_query.ex:498: field `age` does not exist in subquery in query:

from u in subquery(from u in ActSelect.Accounts.User,
  select: %ActSelect.Accounts.User{id: u.id, birthday: u.birthday, bio: u.bio, fb_access_token: u.fb_access_token, fb_id: u.fb_id, first_name: u.first_name, phone: u.phone, gender: u.gender, email: u.email, inserted_at: u.inserted_at, updated_at: u.updated_at}),
  where: u.age == ^21,
  select: u

    (elixir) lib/enum.ex:1925: Enum."-reduce/3-lists^foldl/2-0-"/3
    (elixir) lib/enum.ex:1418: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir) lib/enum.ex:1925: 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
    (stdlib) erl_eval.erl:677: :erl_eval.do_apply/6
    (iex) lib/iex/evaluator.ex:249: IEx.Evaluator.handle_eval/5
    (iex) lib/iex/evaluator.ex:229: IEx.Evaluator.do_eval/3
    (iex) lib/iex/evaluator.ex:207: IEx.Evaluator.eval/3
    (iex) lib/iex/evaluator.ex:249: IEx.Evaluator.handle_eval/5
    (iex) lib/iex/evaluator.ex:229: IEx.Evaluator.do_eval/3
    (iex) lib/iex/evaluator.ex:207: IEx.Evaluator.eval/3
    (iex) lib/iex/evaluator.ex:94: IEx.Evaluator.loop/1
    (iex) lib/iex/evaluator.ex:24: IEx.Evaluator.init/4
    (iex) lib/iex/pry.ex:64: IEx.Pry.pry/2
    (act_select) lib/act_select/accounts/accounts.ex:40: ActSelect.Accounts.list_users/1
    (absinthe) lib/absinthe/resolution.ex:209: Absinthe.Resolution.call/2
    (absinthe) lib/absinthe/phase/document/execution/resolution.ex:209: Absinthe.Phase.Document.Execution.Resolution.reduce_resolution/1