Repository navigation
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1841 +/- ##
==========================================
+ Coverage 83.90% 84.21% +0.31%
==========================================
Files 96 97 +1
Lines 4735 4955 +220
Branches 889 944 +55
==========================================
+ Hits 3973 4173 +200
- Misses 509 520 +11
- Partials 253 262 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
arthurschreiber
left a comment
There was a problem hiding this comment.
Thanks for this, it's a big piece of work, and the negotiation and wire format handling read well. Before going into details, I'd like to change the shape of the public API, because that affects most of vector.ts.
Vector values should be typed arrays only, in both directions. A Float32Array for vector(n) and a Float16Array for vector(n, float16), with no number[] for parameters, bulk load, TVPs or results. Details are in the inline comments.
Other points:
vectorTypeSupportdefaulting to'v2'changes what existing users get back for vector columns today.src/data-types/vector.tshas no unit tests.- The float16 tests don't run against any of our SQL Server jobs. Float16 is a preview feature on SQL Server 2025 and needs
PREVIEW_FEATURESenabled; the last inline comment suggests tests that can run there.
Generated by Claude Code
arthurschreiber
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround. This addresses everything from the last round, and the typed array API reads well. I ran the vector unit tests on Node.js 22 and 24 and the vector integration tests against SQL Server 2025 on both, and they pass.
Three things before merge:
- The PR description is out of date. It still says inputs can be
number[], results arenumber[],'v2'is the default, and float16 values are rounded. Could you rewrite it to match the current API? It will likely end up as the commit message. - An explicit invalid
lengthon a bulk load column makesexecBulkLoadthrow and leaks the row source (inline). - The integration tests skip themselves when negotiation fails, and the login side has no unit tests (inline).
The other inline comments are small and can be follow-ups if you prefer.
Generated by Claude Code
|
Please preserve backward compatibility for existing, non-VECTOR parameters in this PR, including error types and synchronous throw versus asynchronous callback behavior. The current Linux CI failures expose a concrete change in those behaviors; please fix the implementation rather than changing the existing tests to accept it. Reproduction: no running SQL Server is needed. From the repository root, save the following as a temporary const { Connection, Request, TYPES } = require('./src/tedious');
for (const method of ['execSql', 'prepare']) {
const connection = new Connection({ server: 'localhost' });
const request = new Request('SELECT 1', (error) => {
console.log(method, 'callback:', error?.constructor.name, error?.code);
});
request.addParameter('tvp', TYPES.TVP, null);
try {
connection[method](request);
console.log(method, 'returned without throwing');
} catch (error) {
console.log(method, 'synchronous throw:', error.constructor.name, error.code);
}
}On the base implementation, both methods throw Please run these checks on Node.js 22, 24 and 26 and share the results:
Please keep the new VECTOR validation scoped so it does not change existing non-VECTOR error handling. Updating the test setup or expected error alone would not demonstrate that backward compatibility is maintained. |
Summary
Add native support for SQL Server's
VECTORdata type, includingfloat32andfloat16elements, across result sets, parameters, stored procedures, prepared statements, table-valued parameters, and bulk load.Changes
TYPES.Vector, usingFloat32Arrayforvector(n)andFloat16Arrayforvector(n, float16).baseTypewhen there is no value, such asnulland output parameters, bulk-load columns, and TVP columns.vectorTypeSupportconnection option:'off'(default),'v1', or'v2'. Keeping'off'as the default avoids changing results for existing users.Float32ArrayorFloat16Array, withbaseTypeanddimensionsin metadata.Float16Arrayis unavailable, such as on Node.js 22, and rejectfloat16parameters and columns clearly.prepare()through the request callback instead of throwing synchronously.API example
Compatibility
Native VECTOR support requires TDS 7.4 and successful feature negotiation. VECTORSUPPORT version 1 supports
float32; version 2 also supportsfloat16. With the default'off', VECTOR columns continue to be returned as JSON text.On SQL Server 2025,
float16is a preview feature. A version 1 connection returnsfloat16values as JSON text invarchar(max)and still returnsfloat32values natively.Testing
npm run lint: ESLint and TypeScript checks passed.SmallDateTimedaylight-saving test fails in this environment.