-
Notifications
You must be signed in to change notification settings - Fork 51
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
fix: Add check to filter result for logical ops #2573
fix: Add check to filter result for logical ops #2573
Conversation
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.
LGTM, thanks Fred!
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.
LGTM. One minor suggestion.
planner/filter/complex.go
Outdated
@@ -32,6 +32,7 @@ func isComplex(conditions any, seekRelation bool) bool { | |||
for k, v := range typedCond { | |||
if op, ok := k.(*mapper.Operator); ok { | |||
if (op.Operation == request.FilterOpOr && len(v.([]any)) > 1) || |
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.
suggestion: I think this can be simplified a bit and avoid the potential panic from type casting.
switch op.Operation {
case request.FilterOpOr, request.FilterOpAnd, request.FilterOpNot:
if isComplex(v, true) {
return true
}
continue
}
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.
v
can't be anything other than an []any
if it's an _or
or _and
operator and we don't want to classify them as complex if there is only one element in the array.
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.
I don't think this changes the logic though. It just adds another recursive step.
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.
made a change in line with what you suggested. Let me know what you think.
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.
LGTM
Relevant issue(s)
Resolves #2571
Description
This PR adds a check post doc filtering in the fetcher to see if we need to rely on the external conditions instead to ensure a valid filtering operation. This is specially important when filtering with logical operators
_and
and_or
.Tasks
How has this been tested?
make test
Specify the platform(s) on which this was tested: