Detect the filters that are too deep and return an error

This commit is contained in:
Clément Renault 2021-12-07 17:20:11 +01:00
parent 90f49eab6d
commit 32bd9f091f
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
2 changed files with 44 additions and 2 deletions

View file

@ -118,10 +118,12 @@ impl<'a> FilterCondition<'a> {
match self {
FilterCondition::Condition { fid, .. } if depth == 0 => Some(fid),
FilterCondition::Or(left, right) => {
left.token_at_depth(depth - 1).or_else(|| right.token_at_depth(depth - 1))
let depth = depth.saturating_sub(1);
right.token_at_depth(depth).or_else(|| left.token_at_depth(depth))
}
FilterCondition::And(left, right) => {
left.token_at_depth(depth - 1).or_else(|| right.token_at_depth(depth - 1))
let depth = depth.saturating_sub(1);
right.token_at_depth(depth).or_else(|| left.token_at_depth(depth))
}
FilterCondition::GeoLowerThan { point: [point, _], .. } if depth == 0 => Some(point),
FilterCondition::GeoGreaterThan { point: [point, _], .. } if depth == 0 => Some(point),