Closed pgonzaleznetwork closed 3 years ago
Thanks for the feedback - I like the idea about partial parsing and that would be useful for me as well.
I will look into it.
@pgonzaleznetwork - I am working on creating a release for the new version with support for partial query parsing.
ignoreParseErrors
isQueryValid
- because the query is not valid, so it is still reported as suchEven though this query is valid, the apex bind variables are not fully supported - so previously this would have thrown an error.
SELECT Id, (SELECT Id FROM Contacts WHERE Id IN :contactMap.keySet()) FROM Account WHERE Id IN :accountMap.keySet()
parseQuery(soqlQuery, { allowApexBindVariables: true, ignoreParseErrors: true });
Output:
{
"fields": [
{
"type": "Field",
"field": "Id"
},
{
"type": "FieldSubquery",
"subquery": {
"fields": [
{
"type": "Field",
"field": "Id"
}
],
"relationshipName": "Contacts"
}
}
],
"sObject": "Account"
}
I was considering adding some additional parser support for apex bind variables, like accountMap.keySet()
, but then it turned out to be more problematic than I was expecting and as I thought about it, there are just too many variations that would need to be supported which would require a massive amount of work.
Example:
WHERE Id IN :new Map<Id, SObject>([SELECT Id FROM account]).keySet()
For now, I am going to leave the existing parser logic for apex bind variables as-is
Result
If we remove the parenthesis from keySet(), then it works, i.e
No error
Use Case
We are using this library in HappySoup.io to parse queries in apex classes to find where standard fields are used. This error would prevent us from parsing queries to see if a particular standard field is used.
Is there any way to allow for partial success? i.e if you can't parse the WHERE clause, at least we'd like to evaluate the SELECT one.
Thanks!