Its seems that the update in query expression accepts only keyword list (escape/3 in Ecto.Query.Builder.Update). So How can I define a function to dynamically choose a column to update?
Something like this:
def increment_field(column_name, count) when is_atom(field) do
from t in Example.Entity, where: field(t, ^column_name) >= 0, update: [inc: [{^column_name, 1}]]
end
I'v tried this but got malformed :inc in update [{^column_name, 1}], expected a keyword list
I also tried to use figment/2, and field/2, but with no luck.