Reputation: 1155
I've encountered weird issue with the compiler - it claims that my macro is unused despite the fact that I'm calling it in the same module. It may have something to do with using it in where statement but in the end it shouldn't be a problem I guess. Any ideas folks? ;)
defmodule Module do
defmacrop coalesce(left, right) do
quote do
fragment("COALESCE(?, ?)", unquote(left), unquote(right))
end
end
def remove(timestamp \\ Timex.now) do
Schema
|> where([p], coalesce(p.time, ^timestamp) < ^timestamp)
|> Repo.delete_all(returning: select_all(Schema))
end
end
Upvotes: 1
Views: 84
Reputation: 9851
That's because you are not using the macro you defined. You are using Ecto.Query.API.coalesce
Upvotes: 2