You can’t, as AFAIK there is no such functionality in any SQL dialects I know. You would need to build such functionality on your own by using Enum.reduce.
So unless I’m misunderstanding you - LIKE simply doesn’t work that way, it is only designed to match a string to a LIKE pattern.
What are you actually trying to do? There may be a different way of how to do it.
Even this example puzzles me - I’m not even sure this is supposed to work. There must be some unstated, non-typical assumption (e.g. c.is_deleted is an ARRAY rather than a scalar type) here to make this work (if it in fact does).
Hey! I’ve been trying to get this solution to work for me! To give some background on what I am trying to do. I would like to use this function to see which list of strings from the list of list of strings from the fruit column of my table, Food, contains a certain word.
criteria = ((from f in Food, select: f.fruit) |> Repo.all)
The original poster’s question can be solved with a single clause - c.name LIKE ANY (ARRAY['pattern1%', 'pattern2%']) as a fragment.
Unfortunately, that doesn’t work with an array column on the left-hand side of LIKE ANY; PG complains about ERROR: operator does not exist: text[] ~~ text.