pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14688: Wrong results in LIKE operation on JSON Type
2+ messages / 2 participants
[nested] [flat]
* BUG #14688: Wrong results in LIKE operation on JSON Type
@ 2017-06-05 07:18 nblxa@mail.ru
0 siblings, 1 reply; 2+ messages in thread
From: nblxa@mail.ru @ 2017-06-05 07:18 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 14688
Logged by: Ilya Kopylov
Email address: nblxa@mail.ru
PostgreSQL version: 9.6.0
Operating system: Windows 8.1
Description:
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
When I search with 'LIKE' operator and adding '\' symbol, when got result. I
think whis is bug.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #14688: Wrong results in LIKE operation on JSON Type
@ 2017-06-05 14:01 Tom Lane <tgl@sss.pgh.pa.us>
parent: nblxa@mail.ru
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2017-06-05 14:01 UTC (permalink / raw)
To: nblxa@mail.ru; +Cc: 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2017-06-05 14:01 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05 07:18 BUG #14688: Wrong results in LIKE operation on JSON Type nblxa@mail.ru
2017-06-05 14:01 ` Tom Lane <tgl@sss.pgh.pa.us>
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