on-internet
← Community

Postgres inequality behavior with composite values vs. ARRAYs: (a,b,c) vs. ARRAY[a,b,c]

Stack Overflow ·

I've noticed a inconsistent results in Postgres when comparing two ARRAYs using an inequality ( e.g. >, < ), where one element of one ARRAY is NULL. In composite inequalities where one element is NULL, I get the expected result back: NULL. SELECT (11::INT,1,1) > (NULL,9,9) ;--RESULT: "NULL" However with ARRAY[]s comparisons where one element is NULL, I'm getting a BOOLEAN TRUE or FALSE as a result, and not a NULL. SELECT ARRAY[11,1,1] > ARRAY[NULL::INT,9,9] ;--RESULT "FALSE" A similar inconsistency arises when comparing a composite value using a NOT IN() operator (at end of examples). In that

Comments

Sign in or sign up to comment and upvote.

No comments yet.