Ecto query and custom MySQL function with variable arity
问题 I want to perform a query like the following one: SELECT id, name FROM mytable ORDER BY FIELD(name, 'B', 'A', 'D', 'E', 'C') FIELD is a MySQL specific function, and 'B', 'A', 'D', 'E', 'C' are values coming from a List. I tried using fragment, but it doesn't seem to allow dynamic arity known only in the runtime. Except going full-raw using Ecto.Adapters.SQL.query , is there a way to handle this using Ecto's query DSL? Edit: Here's the first, naive approach, which of course does not work: ids