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

not having issues when used twice in same query #864

Open
mstevan opened this issue Dec 30, 2020 · 3 comments
Open

not having issues when used twice in same query #864

mstevan opened this issue Dec 30, 2020 · 3 comments

Comments

@mstevan
Copy link
Contributor

mstevan commented Dec 30, 2020

@mstevan
test-set: not.xml
test-cases: fn-not-5 to fn-not-16

@team
Not behaves weirdly when having two not calls within same query.
not("true") or not("true") for example works but not("true") eq not("true")

List of operators to test with because it throws exception:
Eq,ne,lt,le,gt,ge,=,!=,<,<=,>,>=

Input:
not("true") eq not("true")

Output:
⚠️ ️There was an error.

Code: [XPST0017] (this code can be looked up in the documentation and specifications).

Location information: file:/Users/mstevan/Documents/:LINE:1:COLUMN:15:

Undefined function call; Entered function name and arity doesn't match a defined function signature: "not" called with 1 parameters.

Expected output:
true

@ghislainfourny
Copy link
Member

ghislainfourny commented Jan 5, 2021

That's because in JSONiq not is a prefix operator, not a function call.

When serializing back from XQuery to JSONiq, extra parentheses should be added:

(not "true") eq (not "true")

@mschoeb
Copy link
Collaborator

mschoeb commented Dec 30, 2024

the not() function has been implemented in the meantime but the issue persists. When I write not("some") it works fine and gives false. but not("some") eq true fails with

not("something") eq true
   ^

Code: [XPTY0004]
Message:  "eq": operation not possible with parameters of type "xs:string" and "xs:boolean"

Rumble thinks not("some")is a string. making not explicit with fn:not("some") eq true fixes it.
Not sure if its a parser bug or expected because of the not prefix operator (ideally we could support both?)

@mschoeb
Copy link
Collaborator

mschoeb commented Jan 8, 2025

What actuall happens here is that not("some") eq trueis evaluated as not ("some" eq true) because not binds weaker than eq. ANTLR lookahead if possible could maybe fix this if it knows it should be a functioncall due to the parenthesis.

For JSONiq 3.1 we can consider removing the not prefix operator and just use not() to align better with xquery3.1. This has to be considered/discussed. This would fix the inconsistency. But for now its not a big problem

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

No branches or pull requests

3 participants