Hi,
Is there a way on a query to exclude a where only on a specific field ?
exclude function, reset the where on all fields.
For the moment, my solution is to pass through the wheres and reject the specific field, but it’s a bit ugly… and I don’t even know if it covers all cases.
defp exclude_field_from_where_query(%Ecto.Query{wheres: wheres} = query, field) do
wheres =
wheres
|> Enum.reject(fn %{expr: {_, _, [{{_, _, [_, current_field]}, _, _}]}} ->
current_field == field
end)
%{query | wheres: wheres}
end
Thanks