How do you pass a uuid list to a postgres SQL query?

Since you are checking a value against and array, you should be using WHERE c.user_id <> ALL({{userIds}}) or WHERE NOT (c.user_id = ANY({{userIds}})).

The double quoting just means it is a string, which should be fine. You can run the following in a SQL block to play around with the concept:

with foo as (
SELECT 'a' val, ARRAY['b', 'c', 'd'] ary UNION ALL
SELECT 'b' val, ARRAY['a', 'b', 'c'] ary UNION ALL
SELECT 'c' val, ARRAY['a', 'b', 'd'] ary UNION ALL
SELECT 'd' val, ARRAY['b', 'c', 'd'] ary
)
SELECT *
FROM foo
WHERE val <> ALL(ary);
2 Likes