Re: [BUGS] BUG #14688: Wrong results in LIKE operation on JSON Type - Mailing list pgsql-bugs

From Tom Lane
Subject Re: [BUGS] BUG #14688: Wrong results in LIKE operation on JSON Type
Date
Msg-id 32396.1496671305@sss.pgh.pa.us
Whole thread Raw
In response to [BUGS] BUG #14688: Wrong results in LIKE operation on JSON Type  (nblxa@mail.ru)
List pgsql-bugs
nblxa@mail.ru writes:
> When JSON contains '\\' symbol, then operator '=' works well, but operator
> 'LIKE' return wrong result.

> SELECT '{"Name":"Domen\\Ivan"}'::json ->> 'Name' = 'Domen\Ivan'; -- yields
> 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#FUNCTIONS-LIKE
        regards, tom lane


--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

pgsql-bugs by date:

Previous
From: gdutton@inf.ed.ac.uk
Date:
Subject: [BUGS] BUG #14690: Client GSSAPI / Kerberos auth crash
Next
From: Joe Conway
Date:
Subject: Re: [BUGS] BUG #14682: row level security not work with partitionedtable