Psql unnest in ecto

Thanks for your input!

The solution I came up with is to use a CTE to hold the dynamic values from the unnest:

union_query = 
  "cte_name"
  |> with_cte("cte_name", as: fragment("select my_column from unnest(ARRAY[5, 10, 15]) my_column"))
  |> select([c], %{ my_column: fragment("my_column") }

This query is able to be unioned :tada:

2 Likes