Preserve fractional numbers and Unicode in MSSQL parameters - #6922
Conversation
🦋 Changeset detectedLatest commit: cb834ff 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.
Important
This PR only adds reproduction tests — the implementation fix (changing defaultParameterTypes to use Float and NVarChar) has not been added yet. Merging as-is would land only failing tests.
Reviewed changes
- New test file
DefaultParameterLossRepro.test.ts— two reproduction tests verifying thatInttruncates fractional numbers andVarCharloses Unicode characters through codepage conversion.
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
- Changed
defaultParameterTypesmappings —stringnow usesNVarCharinstead ofVarCharandnumbernow usesFloatinstead ofInt, preserving Unicode strings and fractional JavaScript numbers. - Added unit tests — two tests in
Client.test.tsvalidate that the new type objects'validate()methods preserve the input values. - Added changeset —
@effect/sql-mssqlpatch for the parameter type fix.
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
Default interpolation truncates fractional numbers through Int and can replace Unicode characters through VarChar code-page conversion.
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.
Default parameter types lose numeric and Unicode data
Module:
mssql/MssqlClientAudit ID:
sql-adapters-ms-1Severity / confidence: high / high
What happens
Default interpolation truncates fractional numbers through Int and can replace Unicode characters through VarChar code-page conversion.
Why it happens
The adapter maps every number to Tedious Int and every string to VarChar instead of domain-preserving defaults such as Float and NVarChar.
Expected behavior
Ordinary interpolation must preserve finite JavaScript numbers and Unicode strings unless a caller explicitly chooses narrower SQL types.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/sql/mssql/src/MssqlClient.ts:359-370packages/sql/mssql/src/MssqlClient.ts:713-722View problematic code at
packages/sql/mssql/src/MssqlClient.ts:359-370View exact lines on GitHub
View problematic code at
packages/sql/mssql/src/MssqlClient.ts:713-722View exact lines on GitHub
Reproduction
pnpm test --run packages/sql/mssql/test/DefaultParameterLossRepro.test.tsObserved failure: FAIL: 1.5 validated as 1 and a valid Unicode character became a question mark under CP1252.
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/mssql/test/DefaultParameterLossRepro.test.tsAudit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715fsql-adapters-ms-1Closes EFF-337