Details
Description
A query like `SELECT * FROM _ WHERE (((((type == "6")))))` should be the same as `SELECT * FROM _ WHERE (type == "6")`. But the N1QL parser creates a new expression for every parentheses. Because the parser acts recursively, this can cause exponential slowdown. We should strip the redundant parentheses at the top-level, to avoid creating unnecessary expressions.
We must be careful not to remove all parentheses.