BUG #18510: jsonpath does not support trailing backslash at the end of the query

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: voronaam(at)gmail(dot)com
Subject: BUG #18510: jsonpath does not support trailing backslash at the end of the query
Date: 2024-06-14 20:03:55
Message-ID: 18510-744a9f0c859e3b45@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18510
Logged by: Lex Vorona
Email address: voronaam(at)gmail(dot)com
PostgreSQL version: 16.3
Operating system: Linux (Ubuntu)
Description:

Note that JSONPATH documentation states [1]:

> to write a backslash itself, you must write \\

It works for a backslash as long as it is not the last character in the
input string.

Simplest way to reproduce:

psql (16.3 (Ubuntu 16.3-1.pgdg22.04+1))

postgres=# select '$.field ? (@ like_regex "a\\b")'::jsonpath; -- works
jsonpath
---------------------------------
$."field"?(@ like_regex "a\\b")
(1 row)

postgres=# select '$.field ? (@ like_regex "a\\")'::jsonpath; -- does not
work
ERROR: invalid regular expression: invalid escape \ sequence
LINE 1: select '$.field ? (@ like_regex "a\\")'::jsonpath;
^

Also reproducible with functions like jsonb_path_exists(...) which
automatically cast parameters to jsonpath.

1:
https://www.postgresql.org/docs/current/datatype-json.html#DATATYPE-JSONPATH

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2024-06-14 20:31:47 Re: BUG #18510: jsonpath does not support trailing backslash at the end of the query
Previous Message PG Bug reporting form 2024-06-14 18:00:01 BUG #18509: Logical decoding behaves badly when processing a change record for a table with altered column