Where m is table from a join clause and I would like to order by the sum_total key. The problem is that above query raise an exception that basically tells me that is not a valid query expression.
The reason why you need a fragment is that ecto does not recurse down into the types to build things up, but that can usually be worked around with a fragment.
One more question how can I filter by a column name dynamically?
def by_filter_attribute(query, filter, filter_values) do
from [m, a, mu, p, bf, l] in query,
where: fragment("?.?_id in (?)", ^a, ^filter, ^filter_values)
end