I have the following query:
SELECT users.uuid
FROM users
JOIN users_ext ON users.uuid = users_ext.uuid
WHERE TRUE AND
($1 IS NULL OR users.country IN (ARRAY[$1])) AND
($2 IS NULL OR users.bonus_points IN (ARRAY[$2])) AND
Although I am getting the error: "operator does not exist: text = text[]"
I have tried
$1 IS NULL OR users.country IN ANY(ARRAY[$1]))
But still does not work. How can I get this to work?
2
Answers
This error might be caused by data type mismatch between column and parameter used in comparison. You can check if data type of $1 matches the data type of the users.country column.
It is very likely that you need to change it to:
I am not sure about what $1 / $2 is – could you provide example?