Closed debedb closed 3 months ago
AND
does have higher precedence, the problem would be still there if the operators are reversedI am not sure if there is a problem here. The formatting functions track the operator precedence to minimized the number of parentheses generated. If you reverse the operators, parenthesis will be included.
I ran your ast through the formatter to get a single line with no parenthesis, and it appears correct.
SELECT COUNT(*) AS total_cnt FROM foo WHERE salary > 1000 AND e.hired_date BETWEEN '2020-01-01' AND '2020-12-31' OR salary < 1000 AND e.hired_date BETWEEN '2021-01-01' AND '2021-12-31'
@klahnakoski yes, you are correct; I have tried reversing AND
and OR
and the proper paretheses are there. My mistake. Closing.
Consider the following code:
The AST provided is
The output is
Yet I expect the output to be