Skip to content

fix: parse boolean connection string options correctly#1861

Merged
dhensby merged 1 commit into
tediousjs:masterfrom
dhensby:fix/useutc-connection-string-parsing
May 14, 2026
Merged

fix: parse boolean connection string options correctly#1861
dhensby merged 1 commit into
tediousjs:masterfrom
dhensby:fix/useutc-connection-string-parsing

Conversation

@dhensby
Copy link
Copy Markdown
Collaborator

@dhensby dhensby commented May 14, 2026

Problem

useUTC=False in a connection string is incorrectly parsed as true.

The useutc, stream, and parsejson keys are not part of the upstream MSSQL_SCHEMA, so toSchema() does not include them in its output. They are then added back from the raw parse result as strings (e.g. "False"). The existing !!value coercion converts any non-empty string to true, making it impossible to disable these options via connection strings.

Fix

Extend MSSQL_SCHEMA with the node-mssql-specific keys (useutc, stream, parsejson as boolean, request timeout as number) so that toSchema() handles the type conversion automatically — the same way it already handles encrypt, trustservercertificate, etc.

Tests

Added 7 tests covering True/False/false variations for useUTC, stream, and parseJSON.

Closes #1860

Non-standard boolean options (useUTC, stream, parseJSON) were not part
of the MSSQL_SCHEMA, so they were passed through as raw strings by
the connection string parser. This caused values like "False" to be
coerced to true via the `!!` operator (since any non-empty string is
truthy).

Extend the MSSQL_SCHEMA with these node-mssql-specific keys so that
toSchema() handles the string-to-boolean conversion. Also add
request timeout as a number type.

Closes tediousjs#1860

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dhensby dhensby merged commit 296c38d into tediousjs:master May 14, 2026
47 checks passed
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 12.5.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useUTC=False is not working in connection string

1 participant