Skip to content

fix: parenthesise an arithmetic expression passed as an argument - #41

Merged
Makisuo merged 2 commits into
fix/ch-exact-number-literalsfrom
fix/arith-argument-parens
Oct 23, 2026
Merged

Makisuo merged 2 commits into
fix/ch-exact-number-literalsfrom
fix/arith-argument-parens

Conversation

@Makisuo

@Makisuo Makisuo commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

$.a.sub($.b.add(1)) compiled to a - b + 1. Chains following SQL precedence is documented ($.a.sub(1).div(2) is a - 1 / 2), but an argument is not a chain and no call order could express a - (b + 1). A right-hand argument that is itself arithmetic is now parenthesised; chained SQL is unchanged. docs/expressions.md says how to group (pass the group as an argument).

The fuzz model applies the documented chain precedence and keeps arguments whole; FUZZ_STRICT accepts a list of known-issue ids.

Verification: doc-backed test An arithmetic argument keeps its parentheses; plan fuzz at 20× on Postgres and ClickHouse (12k queries vs the model, nested arithmetic no longer skipped); full suite.


Stack (merge bottom-up):

  1. test(fuzz): property-based fuzzer for the query builder #39 test(fuzz): property-based fuzzer for the query builder
  2. fix(clickhouse): write number literals that read back exactly #40 fix(clickhouse): write number literals that read back exactly
  3. fix: parenthesise an arithmetic expression passed as an argument #41 fix: parenthesise an arithmetic expression passed as an argument
  4. fix: fail with QueryBuilderError instead of throwing on unusable values #42 fix: fail with QueryBuilderError instead of throwing on unusable values
  5. fix: bare select() over a subquery or union selects every alias #43 fix: bare select() over a subquery or union selects every alias
  6. fix(clickhouse): cast array and map comparison literals to the column type #44 fix(clickhouse): cast array and map comparison literals to the column type
  7. fix(postgres): type the two placeholders Postgres would mistype #45 fix(postgres): type the two placeholders Postgres would mistype

🤖 Generated with Claude Code

`arith` wrote `${lhs} ${op} ${rhs}` with no parentheses. For a chain that
is documented: it follows SQL precedence. But a compound argument lost its
boundary too — `$.a.sub($.b.add(1))` compiled to `a - b + 1` — and no call
order can express `a - (b + 1)` then. A right-hand argument built by
`arith` is now parenthesised; chained SQL is unchanged.

The fuzz model groups arguments the same way, and FUZZ_STRICT accepts a
list of known-issue ids to re-enable just those.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 29b0a8b4-caaf-4e97-b403-af9bc4735cd0
📥 Commits

Reviewing files that changed from the base of the PR and between a433599 and 73dfb51.

📒 Files selected for processing: 11
  • .changeset/arith-argument-parens.md
  • docs/expressions.md
  • docs/testing.md
  • src/ch/expr.ts
  • src/docs-examples.test.ts
  • tests/fuzz/compile.fuzz.test.ts
  • tests/fuzz/harness.ts
  • tests/fuzz/known-issues.ts
  • tests/fuzz/literals.fuzz.test.ts
  • tests/fuzz/model.ts
  • tests/fuzz/queries.fuzz.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Makisuo
Makisuo added this pull request to stack #46 October 23, 2026 00:18
@Makisuo Makisuo changed the title fix: parenthesise an arithmetic expression passed as an argument fix(clickhouse): write number literals that read back exactly Oct 23, 2026
@Makisuo Makisuo changed the title fix(clickhouse): write number literals that read back exactly fix: parenthesise an arithmetic expression passed as an argument Oct 23, 2026
@Makisuo
Makisuo merged commit 36499ea into main Oct 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant