Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dHsZv-0003Ag-HS for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Jun 2017 14:01:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dHsZv-0000cP-0h for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Jun 2017 14:01:55 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dHsZu-0000cF-FX for pgsql-bugs@postgresql.org; Mon, 05 Jun 2017 14:01:54 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dHsZr-0005CG-Ub for pgsql-bugs@postgresql.org; Mon, 05 Jun 2017 14:01:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v55E1jRU032397; Mon, 5 Jun 2017 10:01:45 -0400 From: Tom Lane To: nblxa@mail.ru cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14688: Wrong results in LIKE operation on JSON Type In-reply-to: <20170605071822.1453.53540@wrigleys.postgresql.org> References: <20170605071822.1453.53540@wrigleys.postgresql.org> Comments: In-reply-to nblxa@mail.ru message dated "Mon, 05 Jun 2017 07:18:22 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <32395.1496671305.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 05 Jun 2017 10:01:45 -0400 Message-ID: <32396.1496671305@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org nblxa@mail.ru writes: > When JSON contains '\\' symbol, then operator '=3D' works well, but opera= tor > 'LIKE' return wrong result. > SELECT '{"Name":"Domen\\Ivan"}'::json ->> 'Name' =3D 'Domen\Ivan'; -- yie= lds > true > SELECT '{"Name":"Domen\\Ivan"}'::json ->> 'Name' LIKE 'Domen\Ivan'; -- > yields false > SELECT '{"Name":"Domen\\Ivan"}'::json ->> 'Name' LIKE 'Domen\\Ivan'; -- > yields true I think you've forgotten that backslash is an escape character in LIKE patterns. You could use ... LIKE 'Domen\Ivan' ESCAPE '' if you don't want that behavior. https://www.postgresql.org/docs/current/static/functions-matching.html#FUNC= TIONS-LIKE regards, tom lane --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs