Hi there,
When I try to make up a new hex (something like ransack in ruby land) I have the next problem:
===
defp match(%Rule{op: :eq, field: field, assoc: nil}, value, query) do
quote do: unquote(query) |> where([q], q.unquote(field) == ^unquote(var!(value)))
end
defp match(%Rule{op: :eq, field: field, assoc: assoc}, value, query) do
quote do
unquote(query)
|> join(:inner, [r], l in assoc(r, unquote(var!(assoc))))
|> where([q], q.unquote(field) == ^unquote(var!(value)))
end
end
===
first function works well, but when I try to pass "unquote(query)" (regular "Ecto.Query" struct) to macros "join", I got an exception like this:
===
** (CompileError) nofile: invalid quoted expression: #Ecto.Query<from o in Order>
===
Did I do something wrong? Why "where" and "join" macros have different semantics? And, of course is there other way to build dynamic queries?
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-talk/_7Ua6-qt8uc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/aef453ae-ae54-4e66-9921-deeef3e7225f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.