Building a dynamic, nested WHERE IN query with Ecto

Hi all,

I have a query that is being built by piping several where functions together. At one point I need to add a where clause that, in SQL, should look like this:

... AND (col1,col2) IN ((val1, val2), (val1, val2), ...) ...

For context, the ((val1, val2)…) would be generated dynamically and guaranteed to be safe SQL. I’ve tried several approaches to building this (fragments, macros with fragments, `[t.col1, t.col2] IN ^values_list’) but keep hitting roadblocks. It looks like there is an “unsafe_fragment” function coming with Ecto 3.0 which would solve this issue.

Has anyone had success building out a query like this using Ecto?

I’ve needed the same thing but just end up either falling down to unsafe_fragment or and/or branch horrors that I know don’t optimize well… >.>

Would be nice if Ecto supported tuple comparisons for such things so we could do where: {a.b, a.c} in ^list_of_tuples. Or lists instead of tuples, probably lists now that I think of it…