Why does one of these very similar jsonpaths work, but not the other?

Viewed 1232

Bumped into this while debugging a query from the ORM and have no idea why it happens. Asking mostly out of curiosity. In PostgreSQL 12.5 the following occurs:

-- All good:
select ('$[*] ? (@.live_at <= 2020-11-18)')::jsonpath

jsonpath                               |
---------------------------------------|
$[*]?(@."live_at" <= (2020 - 11) - 18) |

-- But then:
select ('$[*] ? (@.live_at <= 2020-05-18)')::jsonpath

SQL Error [42601]: ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
  Position: 9
  SQL Error [42601]: ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
  Position: 9
    SQL Error [42601]: ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
  Position: 9
      SQL Error [42601]: ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
  Position: 9
        ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
  Position: 9
        ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
  Position: 9

I've a suspicion that this is related to octal representation, but node seems to eat 2020-05-18 just fine. What gives?

0 Answers
Related