fix: keep spaces around - operator in dialects with dashed identifiers#953
Conversation
In BigQuery (and any dialect allowing dashes inside identifiers) the denseOperators option turned "a - b" into "a-b", which then re-parses as a single dashed identifier - corrupting the query. Skip densing the "-" operator for those dialects so the output round-trips.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR adds support for dialect-specific handling of the minus operator to prevent accidental merging of ChangesIdentifier dashes operator spacing
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi, sorry for the delay. This is probably the best pull request I've received over the years. Very well thought through fix for this quirky bug. Thanks a lot. |
|
Released in 15.8.2 |
|
@coderabbitai why did you write this?
and can you suppress it for all future reviews? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain⚙️ CodeRabbit configuration inspected Length of output: 5107
pre_merge_checks:
docstrings:
mode: warning
threshold: 80It checks docstring coverage across changed files and warns when it falls below the 80% threshold. For a TypeScript SQL formatter library, that threshold is definitely not a sensible default. To disable it, add (or update) a reviews:
pre_merge_checks:
docstrings:
mode: disabledThat will stop the check from running on future PRs entirely. Alternatively, you can lower |
With
denseOperators: trueon BigQuery, a subtraction likea - bcomes out asa-b. That's not just ugly: BigQuery allows dashes inside identifiers, so the densed output re-parses as a single identifiera-b, andformat(format(sql))no longer matchesformat(sql).a - foo(y)is worse — it becomesa-foo (y), turning the expression into an identifier followed by a call.The fix is to leave the
-operator spaced in dialects that allow dashed identifiers (currently just BigQuery). I derived that flag from the existingidentChars.dashestokenizer option so there's a single source of truth. Numeric cases like1 - 2were already safe (the-is parsed into the literal), so this only affects the identifier case.The shared dense-operator test in
operators.tswas actually asserting the brokenfoo-baroutput for BigQuery; I scoped that to the dashed-identifier dialects and added a BigQuery regression test.Summary by CodeRabbit
Release Notes
-operator in dialects that support dashes in identifiers, such as BigQuery. When dense operator formatting is enabled, spaces around the-operator are now properly preserved to prevent expressions from being incorrectly merged into dashed identifiers.