Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regex-expr and contain-expr are missing lhs #120

Closed
cabo opened this issue Sep 16, 2021 · 5 comments
Closed

regex-expr and contain-expr are missing lhs #120

cabo opened this issue Sep 16, 2021 · 5 comments

Comments

@cabo
Copy link
Member

cabo commented Sep 16, 2021

While this may be a bit premature as long as we don't know what the rhs of contain-expr should be, it is missing its lhs.

contain-expr = in-op container
in-op        = " in "                                 ; in operator

What is in the container?

@cabo
Copy link
Member Author

cabo commented Sep 16, 2021

Oh, and the same with regex-expr:

regex-expr   = regex-op regex

@cabo cabo changed the title contain-expr is missing lhs regex-expr and contain-expr are missing lhs Sep 16, 2021
@goessner
Copy link
Collaborator

Well ... good point. Starting with these examples:

@.color in ["red","green","blue"]
@.color in $.colors
$.color in @.colors
"color" in @.colors
"color" in @
@.index in [2,4,7]
@.index in $.indices
$.index in @.indices
42 in @.indices
42 in @
  • lhs is restricted to a primitive value (possibly only number and string). lhs holding a complex value will fail, i.e. no selection occurs.
  • rhs must be resolved to a complex value (array or object). rhs holding a simple value will fail, i.e. no selection occurs.

Given this we have something like this ...

contain-expr = (rel-path-val / json-path / number / string-literal) in-op container
container =  (rel-path-val / json-path / array-literal)

... as a starting proposal.

@cabo
Copy link
Member Author

cabo commented Sep 17, 2021

(From 2021-09-17 interim:)
So we would have syntax for array literals composed of primitive values only (subset of JSON array literals); other JSON array literals cause a syntax error. (Empty array literals should be allowed to simplify code generation.)
A LHS evaluating to a complex value would not match.
The path on the RHS may also yield an array, we would match against every single element of that like we would match against a literal array.
Example: "color" in @.colors

tending towards consensus on:
@.color in $.colors
if $.colors is an array of structured values, @.color is a single structured value?
➔ only match primitive values from the LHS (counterintuitive!?)
@.color = [128, 255, 17] ➔ no selection
even if $.color = [[128, 255, 17], [1, 2, 3]]
(we cannot avoid structured data to turn up in a query, but we don't match)
Avoid deep equals! (We already avoid it in simple comparisons.)

@goessner
Copy link
Collaborator

goessner commented Nov 2, 2021

Reminder: lhs of regex-op ...

From

regex-expr   =   regex-op regex

to

regex-expr   = rel-path / json-path /                 ; path to string value
                      string-literal
                      regex-op regex

as a proposal.

@cabo
Copy link
Member Author

cabo commented Jan 17, 2022

Fixed in 9da13ab

(Still needs resolution of #70 to become active.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants