Bind inferred ClickHouse numbers with fraction-preserving types - #6908
Conversation
🦋 Changeset detectedLatest commit: 41fd1e3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Reproduction test for ClickHouse fractional-number binding — adds
NumberBindingRepro.test.tsthat constructs aStatement-backed compiler, compilessql`SELECT ${1.5}`, and asserts the placeholder is{p1: Float64}. Confirmed to fail against the current code (which emitsDecimalfor allnumbervalues atClickhouseClient.ts:487).
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — since the prior review at c64d7de:
- Changed inferred number type from
DecimaltoFloat64—typeFromUnknowninClickhouseClient.ts:487now maps all JavaScriptnumbervalues toFloat64, which faithfully preserves fractional digits unlike the previous bareDecimal(which hadDecimal(10, 0)semantics that discarded them). - Relocated the reproduction test — merged the standalone
NumberBindingRepro.test.tsintoClient.test.ts, replacing the stub"should work"test with the fractional-number assertion. - Added changeset — patch release note for
@effect/sql-clickhouse.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Summary
Ordinary fractional JavaScript numbers are compiled as bare Decimal parameters, whose Decimal(10, 0) semantics discard fractional digits.
Important
This PR starts with focused failing reproduction tests. Add the implementation fix to this same branch; CI is expected to fail until that fix is included.
Fractional numbers bind as scale-zero Decimal values
Module:
clickhouse/ClickhouseClientAudit ID:
sql-adapters-ch-3Severity / confidence: high / high
What happens
Ordinary fractional JavaScript numbers are compiled as bare Decimal parameters, whose Decimal(10, 0) semantics discard fractional digits.
Why it happens
Every inferred number uses ClickHouse Decimal rather than a fraction-preserving type such as Float64.
Expected behavior
Default interpolation must preserve finite JavaScript numbers unless the caller explicitly selects a narrower parameter type.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/sql/clickhouse/src/ClickhouseClient.ts:477-499packages/sql/clickhouse/src/ClickhouseClient.ts:510-527View problematic code at
packages/sql/clickhouse/src/ClickhouseClient.ts:477-499View exact lines on GitHub
View problematic code at
packages/sql/clickhouse/src/ClickhouseClient.ts:510-527View exact lines on GitHub
Reproduction
pnpm test --run packages/sql/clickhouse/test/NumberBindingRepro.test.tsObserved failure: FAIL: the compiler emitted bare Decimal instead of Float64.
Implementation handoff
The initial reproduction tests on this branch are the regression specification for the implementation fix that should follow in this PR.
pnpm test --run packages/sql/clickhouse/test/NumberBindingRepro.test.tsAudit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715fsql-adapters-ch-3Closes EFF-342