Skip to content

fix: treat an empty Encrypt value in a connection string as not set - #1960

Merged
dhensby merged 1 commit into
tediousjs:masterfrom
dhensby:claude/empty-encrypt-connection-string-bcde1d
Nov 18, 2026
Merged

dhensby merged 1 commit into
tediousjs:masterfrom
dhensby:claude/empty-encrypt-connection-string-bcde1d

Conversation

@dhensby

@dhensby dhensby commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

What this does:

A connection string with an empty Encrypt value, for example Server=h;Encrypt=;Database=d, turned encryption off with tedious. A connection string that leaves Encrypt out turns it on, because tedious defaults to encrypt: true. An empty value is malformed, but node-mssql now handles it the same as a left-out key.

This change needs @tediousjs/connection-string 1.1.2 or later. That release gives the schema default for an empty boolean or number value, and keeps the key in the toSchema() result. node-mssql now overrides encrypt in its schema with no default, so an empty value gives undefined. The parser sets options.encrypt only when the value is a boolean.

Connection string tedious encrypt msnodesqlv8 Encrypt
Encrypt left out true (no change) No (no change)
Encrypt= or Encrypt={ } true (was false) No (no change)
Encrypt=true or Encrypt=yes true (no change) Yes (no change)
Encrypt=false or Encrypt=no false (no change) No (no change)

The new unit tests cover each row, and check that the pair after an empty Encrypt still parses. The empty-value tests fail before the fix and pass after it. Lint and all 296 unit tests pass. No live SQL Server integration tests were run.

Related issues:

Pre/Post merge checklist:

  • Changelog is maintained through release notes, per CHANGELOG.txt.

🤖 Generated with Claude Code

A connection string with an empty Encrypt value, for example
`Server=h;Encrypt=;Database=d`, set `options.encrypt` to false. A
connection string without Encrypt leaves `options.encrypt` unset, so
tedious uses its default and encrypts. An empty value now gives the
same result as a left-out key.

@tediousjs/connection-string 1.1.2 gives the schema default for an
empty boolean value. The encrypt override in NODE_MSSQL_SCHEMA has no
default, so an empty value gives undefined, and the parser sets
`options.encrypt` only when the value is a boolean. Explicit values
do not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhensby
dhensby marked this pull request as ready for review November 18, 2026 22:55
@dhensby
dhensby merged commit 3505c8f into tediousjs:master Nov 18, 2026
139 of 141 checks passed
@dhensby
dhensby deleted the claude/empty-encrypt-connection-string-bcde1d branch November 18, 2026 22:56
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 12.7.15 🎉

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.

1 participant