U117: Op ANY/ALL (array) requires array

Category: Application / User Errors
SQLSTATE: 42809 (Class 42 — Syntax Error or Access Rule Violation: wrong_object_type)
Urgency: low

Example Postgres Log Output:

ERROR: op ANY/ALL (array) requires array on right side at character 33
STATEMENT: SELECT * FROM x WHERE id = ANY ($1)

Explanation:

Usually you would see this log event when using parameterized queries together with the ANY/ALL expression, like this:

SELECT * FROM x WHERE id = ANY ($1)

When $1 has a value like {1, 2} this query will run correctly. However, when you pass in a single value instead of an array (e.g. 1) you will receive this error notice.

Recommended Action:

Ensure your application code always generates an array value when passing data to ANY/ALL, even for single value arrays.

Learn More:


Download Free eBook: The Top 6 Postgres Log Events
Couldn't find what you were looking for or want to talk about something specific?
Start a conversation with us →