jetstreamapp / soql-parser-js

Javascript SOQL parser
https://jetstreamapp.github.io/soql-parser-js/
MIT License
79 stars 20 forks source link

Invalid NOT query can be parsed without an error while ignoreParseErrors is disabled #201

Open ghingis opened 2 years ago

ghingis commented 2 years ago

Description

This is a valid query:

SELECT AnnualRevenue FROM Account WHERE Name <> NULL AND (NOT (AnnualRevenue > 0))

This is also a valid query:

SELECT AnnualRevenue FROM Account WHERE Name <> NULL AND (NOT AnnualRevenue > 0)

And this is not a valid query:

SELECT AnnualRevenue FROM Account WHERE Name <> NULL AND NOT (AnnualRevenue > 0)

This will throw a unexpected token: 'NOT' on Salesforce.

Yet the parser can parse both without an issue.

EDIT: I added another scenario for a valid query if the negated term is only a single expression.

paustint commented 2 years ago

@ghingis - Thanks for bringing this up. NOT can be a tricky one, I will take a look.