-
Notifications
You must be signed in to change notification settings - Fork 165
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
Prevent OR’ing of filters containing nested paths. #799
Conversation
A filter with nested paths will result in several matches chained together. Those matches are nessary to have the nodes holding the properties we want to filter on. While at first it may seem trivial to think that adding a nested filter with its own match by an OR just doing an OPTIONAL MATCH, this is wrong, as the first part of the OR would need to be marked as OPTIONAL as well. In the end trying to do so, would create very brittle Cypher statements. Instead of, this commit improves the current checks into a single place and adds a couple of tests for it. A query is not created when any of the filters in the chain is nested AND any other is to be chained with OR (when there is actually more than 1 filter).
Codecov Report
@@ Coverage Diff @@
## master #799 +/- ##
============================================
+ Coverage 80.33% 80.41% +0.07%
- Complexity 3030 3039 +9
============================================
Files 277 277
Lines 9246 9253 +7
Branches 1381 1381
============================================
+ Hits 7428 7441 +13
+ Misses 1307 1303 -4
+ Partials 511 509 -2
Continue to review full report at Codecov.
|
boolean orIsPresent = StreamSupport.stream(filters.spliterator(), false) | ||
.anyMatch(f -> BooleanOperator.OR == f.getBooleanOperator()); | ||
boolean nestedOrDeepNestedFilterPresent = StreamSupport.stream(filters.spliterator(), false) | ||
.anyMatch(f -> f.isNested() || f.isDeepNested()); | ||
|
||
if (orIsPresent && nestedOrDeepNestedFilterPresent) { | ||
throw new UnsupportedOperationException( | ||
"Filters containing nested paths cannot be combined via the logical OR operator."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I correct that this will forbid cases which are still can be supported?
A filter with nested paths will result in several matches chained together. Those matches are nessary to have the nodes holding the properties we want to filter on. While at first it may seem trivial to think that adding a nested filter with its own match by an OR just doing an OPTIONAL MATCH, this is wrong, as the first part of the OR would need to be marked as OPTIONAL as well. In the end trying to do so, would create very brittle Cypher statements. Instead of, this commit improves the current checks into a single place and adds a couple of tests for it.
A filter with nested paths will result in several matches chained together. Those matches are nessary to have the nodes holding the properties we want to filter on.
While at first it may seem trivial to think that adding a nested filter with its own match by an OR just doing an OPTIONAL MATCH, this is wrong, as the first part of the OR would need to be marked as OPTIONAL as well.
In the end trying to do so, would create very brittle Cypher statements.
Instead of, this commit improves the current checks into a single place and adds a couple of tests for it.
A query is not created when any of the filters in the chain is nested AND any other is to be chained with OR (when there is actually more than 1 filter).
This closes #796.