SQL ignore null array with WHERE IN UNNEST clause

Okay I’m a really ashamed of myself because when I was writing this question I found solution myself.

You can just do it like this

SELECT * FROM listening_history WHERE 
(composition_id = ANY(%(arr)s) OR %(arr)s is NULL) 
limit 50

I am really ashamed of myself

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top