Repository navigation
fix(grammar): parse || below + and -, like sqlglot and PostgreSQL #749
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,8 @@ generated parser is not committed. | |
| The precedence levels follow the list in the spec's "Operator Precedence" section. Two points | ||
| are not decided there: | ||
|
|
||
| - `||` is accepted, at the level of `+` and `-`. The spec's portable form is `CONCAT(a, b)`; | ||
| - `||` is accepted, at a level of its own below `+` and `-` (above comparisons), like sqlglot and | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm echoing @MrBlack1995 comment here: keeping I suggest updating this bullet to something like: |
||
| PostgreSQL: `a || b + c` is `a || (b + c)`. The spec's portable form is `CONCAT(a, b)`; | ||
| `a || b` only appears as a dialect form. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This clause conflicts with expression_language.md, which lists |
||
| - Comparisons do not chain: `a = b = c` needs parentheses. | ||
|
|
||
|
|
||
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.
Both of these expressions already parse cleanly on
mainunder the old# additiveValuerule, so adding them tovalid.txtdoesn't guard against a precedence regression.Could we add an AST-shape test in
core-spec/grammar/tests/test_expression_grammar.py(mirroringtest_multiplication_binds_tighter_than_addition) to pin that+binds tighter than||(and optionally that||remains left-associative)?For example: