pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: david@justatheory.com
Subject: BUG #17694: In JSONPath expressions, characters between leading $ and dot appear to be ignored
Date: Wed, 23 Nov 2022 20:11:04 +0000
Message-ID: <17694-2f7d9576ae277d64@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      17694
Logged by:          David Wheeler
Email address:      david@justatheory.com
PostgreSQL version: 15.1
Operating system:   macOS
Description:        

The correct way to specify an absolute JSON path expression is to start with
`$.`, as in:

```
david=# select '{"foo": 1}' @? '$.foo';
 ?column? 
----------
 t
```

If, however, you omit the dot (`.`), the expression incorrectly always
evaluates to true!

```
david=# select '{"foo": 1}' @? '$foo';
 ?column? 
----------
 t

david=# select '{"foo": 1}' @? '$"foo bar"';
 ?column? 
----------
 t

david=# select '{"foo": 1}' @? '$"foo bar".bar';
 ?column? 
----------
 f
```

It looks like the text between the `$` and `.` is ignored. I don't think
this is right. Shouldn't it be a syntax error? Seems to properly complain if
using the same pattern in subpaths:

```
david=# select '{"foo": 1}' @? '$.foo"foo bar"';
ERROR:  syntax error at or near """ of jsonpath input
LINE 1: select '{"foo": 1}' @? '$.foo"foo bar"';
```



view thread (7+ messages)  latest in thread

Message-ID: <17694-2f7d9576ae277d64@postgresql.org>
Permalink:  ../17694-2f7d9576ae277d64@postgresql.org/
Also on:    postgresql.org/message-id/17694-2f7d9576ae277d64@postgresql.org

 · 

reply

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: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, david@justatheory.com
  Subject: Re: BUG #17694: In JSONPath expressions, characters between leading $ and dot appear to be ignored
  In-Reply-To: <17694-2f7d9576ae277d64@postgresql.org>

* 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