Re: != ANY(array) does not behave as expected

2018-12-07 Thread Andrew Gierth
> "Chris" == Chris Wilson writes: Chris> However, if we try to invert it by using the != operator, then Chris> we get unexpected results: Mr. De Morgan would like a word. https://en.wikipedia.org/wiki/De_Morgan%27s_laws In short, if you have a condition of the form (a OR b) and you want t

Re: != ANY(array) does not behave as expected

2018-12-07 Thread Ken Tanzer
On Fri, Dec 7, 2018 at 5:21 AM Thomas Kellerer wrote: > Thomas Kellerer schrieb am 07.12.2018 um 13:48: > > Chris Wilson schrieb am 07.12.2018 um 13:39: > >> However, if we try to invert it by using the != operator, then we get > unexpected results: > >> > >> select * from foo where id NOT IN (1,

Re: != ANY(array) does not behave as expected

2018-12-07 Thread Thomas Kellerer
Thomas Kellerer schrieb am 07.12.2018 um 13:48: > Chris Wilson schrieb am 07.12.2018 um 13:39: >> However, if we try to invert it by using the != operator, then we get >> unexpected results: >> >> select * from foo where id NOT IN (1, 2); /* returns row 3 only, as expected >> */ >> select * from

Re: != ANY(array) does not behave as expected

2018-12-07 Thread Thomas Kellerer
Chris Wilson schrieb am 07.12.2018 um 13:39: > However, if we try to invert it by using the != operator, then we get > unexpected results: > > select * from foo where id NOT IN (1, 2); /* returns row 3 only, as expected > */ > select * from foo where id != ANY (ARRAY[1, 2]); /* returns all rows,

!= ANY(array) does not behave as expected

2018-12-07 Thread Chris Wilson
Dear Postgres users, I like using ANY(array) instead of IN (...), as we can pass the array as binary data, avoiding the need to render its contents (which might be integers) into a SQL string, for Postgres to parse them back into integers again, and it also works with an empty list