Open AnyhowStep opened 3 years ago
The same problem for equality operator precedence, https://www.db-fiddle.com/f/9F9ZCGV3QDs6fPysLMQ7Yh/0
SELECT
1 = 2 BETWEEN 0 AND 1,
(1 = 2) BETWEEN 0 AND 1,
1 = (2 BETWEEN 0 AND 1);
1 = 2 BETWEEN 0 AND 1 | (1 = 2) BETWEEN 0 AND 1 | 1 = (2 BETWEEN 0 AND 1) |
---|---|---|
0 | 1 | 0 |
Related: https://github.com/AnyhowStep/sql-compiler/issues/27
https://www.db-fiddle.com/f/eLqMAKQHmfzCVFKMB9raFn/0
https://dev.mysql.com/doc/refman/5.7/en/operator-precedence.html
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_yacc.yy#L9360
Given this,
We can have,
Or,
According to the documentation, it should parse from left to right. So, the first choice. But the grammar rules are written such that it parses from right to left.