fix: pass dataLength to getMssqlType in valueCorrection#1855
Merged
dhensby merged 1 commit intotediousjs:masterfrom May 4, 2026
Merged
fix: pass dataLength to getMssqlType in valueCorrection#1855dhensby merged 1 commit intotediousjs:masterfrom
dhensby merged 1 commit intotediousjs:masterfrom
Conversation
valueCorrection() was calling getMssqlType() without the length argument, causing IntN, FloatN, MoneyN and DateTimeN types to always resolve to their smallest variant (TinyInt, Real, SmallMoney, SmallDateTime). This meant value handlers registered for BigInt, Int, SmallInt, Float, Money, or DateTime were never invoked. Closes tediousjs#1853 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes a driver-specific bug in the tedious implementation where valueCorrection() failed to pass dataLength into getMssqlType(), causing IntN/FloatN/MoneyN/DateTimeN values to be misclassified as their smallest variants and therefore dispatch to the wrong (or no) valueHandler.
Changes:
- Passes
metadata.dataLengthtogetMssqlType()inlib/tedious/request.jsso N-types resolve to the correctsql.TYPES.*. - Adds an integration test to ensure
valueHandlerdispatch works correctly forBigInt,Int, andTinyInt. - Wires the new test into both the tedious and msnodesqlv8 integration test runners.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/tedious/request.js | Fixes N-type disambiguation for valueHandler dispatch by providing metadata.dataLength to getMssqlType(). |
| test/common/tests.js | Adds an integration test asserting correct valueHandler routing for IntN-family integer types. |
| test/tedious/tedious.js | Registers the new shared integration test in the tedious test suite. |
| test/msnodesqlv8/msnodesqlv8.js | Registers the new shared integration test in the msnodesqlv8 test suite. |
|
🎉 This PR is included in version 12.5.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
valueCorrection()callsgetMssqlType(metadata.type)without passing thelengthargument. ThegetMssqlTypefunction useslengthto disambiguate nullable N-types (IntN, FloatN, MoneyN, DateTimeN) — without it, they always resolve to the smallest variant:This means
valueHandlerentries registered forBigInt,Int,SmallInt,Float,Money, orDateTimeare never invoked — only the smallest variant handler fires.Note: column metadata types (via
createColumns) are not affected — that call site already passescolumn.dataLengthcorrectly.Closes #1853
Fix
One-liner: pass
metadata.dataLengthas the second argument togetMssqlType()invalueCorrection().Tests
Added an integration test that registers separate value handlers for
BigInt,Int, andTinyInt, then queries all three types. Without the fix, only theTinyInthandler fires; with the fix, each handler fires exactly once.