skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. It is very likely that you need to change it to:

    ($1 IS NULL OR users.country IN ($1))
    

    I am not sure about what $1 / $2 is – could you provide example?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search