Send an the generated query from an Ecto.Query to a postgres function

I tried that, visible in my first example

Oops, need to improve my reading skills, sorry about that!

It does indeed appear that there’s no way within the Elixir ecosystem to obtain a “standalone” string of the resulting query: even postgrex relies on sending the prepared query and its parameters separately. This was also touched on here: Ecto query into Plain SQL - #9 by LostKobrakai

send that to the PostgreSQL function

Could you maybe expand on this part? By “send” do you literally mean to send to a different node, or just to give it as a param? Does something like this work?

var = 0                                             
query = from t0 in "table", where: t0<^var, select: t0
Repo.all(from q in query, select: fragment("postgress_function(?)", ^q))

Based on https://medium.com/@Mike_Andr/how-to-use-ectos-fragment-for-building-complex-queries-1379b95a2904