soql-parser-js icon indicating copy to clipboard operation
soql-parser-js copied to clipboard

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

Open ghingis opened this issue 3 years ago • 1 comments

  • [ ] Feature
  • [x] Bug

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.

ghingis avatar Jul 19 '22 13:07 ghingis

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

paustint avatar Jul 20 '22 01:07 paustint