From: Tom Lane <tgl@sss.pgh.pa.us>
To: baurzhansahariev@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18218: NOT LIKE ANY returns same result as LIKE ANY when array items are wrapped into E''
Date: Thu, 30 Nov 2023 08:06:22 -0500
Message-ID: <461815.1701349582@sss.pgh.pa.us> (raw)
In-Reply-To: <18218-8cbdd922e41ea291@postgresql.org>
References: <18218-8cbdd922e41ea291@postgresql.org>
PG Bug reporting form <noreply@postgresql.org> writes:
> select 'TextToMatch' like any (array[E'Te\%tch', E'nomatch']); -- true,
> correct
> select 'TextToMatch' NOT like any (array[E'Te\%tch', E'nomatch']); -- true
> but must be false because it's a negated version of the expression above
No, it is not. "NOT LIKE" is the operator to apply in this context,
so the second expression returns true if the test string is NOT LIKE
either of the array elements. You could write
NOT ('TextToMatch' like any (array[E'Te\%tch', E'nomatch']))
to get the behavior you are after. Or write NOT LIKE ALL,
as Orlov suggests.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, baurzhansahariev@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18218: NOT LIKE ANY returns same result as LIKE ANY when array items are wrapped into E''
In-Reply-To: <461815.1701349582@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox