Ecto unknown number of or clauses

Hi All, forgive the brevity of this message as I’m currently on my phone.

I am currently having trouble understanding how I can combine an unknown number of OR clauses in ecto. I am using the dynamic macro to build a list of these OR clauses but when passing this to a where query I do not know how to combine them.

Simply passing the list as or_where: ^list_dynamic_queries doesn’t work. So I assume I have to Enum.join this list somehow with the OR parts of the query but not sure how.

Ok should have been obvious but I can just reduce this with a reduction function to combine the dynamic queries i.e.

Enum.reduce(clauses, fn clause, accum -> clause or accum)

2 Likes