mattbishop / sql-jsonpath-js

JS implementation of the SQL/JSONPath dialect, from SQL2016.
MIT License
0 stars 0 forks source link

Support `to` array element ranges #8

Closed mattbishop closed 2 years ago

mattbishop commented 2 years ago

One can reference a range of elements in an array with the to keyword:

JeffML commented 2 years ago

I'll look into this one first. Seems simple.

JeffML commented 2 years ago

Reference examples of valid element accessor syntax:

$[1 to last] $[1, 3 to 5] $[1, 3 to 0.5 last] $[0, last-1 to last, 5] $[1, 3 to 0.5 last] $[1, 3 to 0.5 last - 1] $[1, 3 to (0.5 last) + 1]

wildcard accessor would be stand-alone, I think: [*]

More elaborate expressions might be allowed by Postgres, e.g. [last - ((7+1)*last/2)], but I question where those are of practical use.

The spec mentions wff and defines it as a well-formed formula, but doesn't define 'well-formed formula'.

mattbishop commented 2 years ago

Parser completed in #13. Thanks Jeff!