Allow "not like" statements to be used with other filters #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi - first, thank you for sharing your blog and this code, it has been really helpful for our team in reducing test execution time and improving code coverage.
We noticed an issue where we were converting a large query that used multiple "not like" statements in it that the query was not valid. The issue seems to be that the correct syntax for a "not like" statement is to have it be wrapped in parentheses so multiple where clauses will work correctly.
For example, the following code would generate a working query:
However, it seems that if we add any other criteria to the query then it will result in a non-valid SOQL query. This seems to be the case if we add any other filter criteria to the where clause, not just if we use multiple "not like" filters.
Instead, the solution seems to be that if we wrap all "not like" queries in parentheses and format the string to include the field name and the value, then we could generate a working query like the one below:
I have written a basic unit test and updated the other two unit tests to expect the added parentheses. The unit tests passed when I ran the updated code in a personal dev sandbox.
Let me know if you have any comments or suggested changes to this!