Skip to content

fix: use schema defaults for empty boolean and number values - #300

Merged
dhensby merged 1 commit into
tediousjs:masterfrom
dhensby:fix/empty-value-defaults
Nov 18, 2026
Merged

dhensby merged 1 commit into
tediousjs:masterfrom
dhensby:fix/empty-value-defaults

Conversation

@dhensby

@dhensby dhensby commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

An empty value for a boolean or number key, such as Connect Timeout=, now gives the schema default in toSchema(). Before, an empty boolean value gave false, and an empty number value gave NaN.

Changes

  • toSchema() uses the schema default for an empty, or whitespace-only, boolean or number value. The key stays in the result, with undefined if the schema has no default. An empty string value, such as Password=, is still ''. get() does not change.

Behaviour changes

An empty value is not a valid connection string value, so these changes affect only malformed input:

  • Connect Timeout= now gives 15, not NaN, and Max Pool Size= gives 100.
  • An empty or whitespace-only boolean value gives the key's default. For example, Pooling= now gives true, and TrustServerCertificate={ } gives false.
  • Encrypt= still gives false, the schema default. Encrypt={ } now also gives false; before, it gave true.

A connection string that leaves a key out gives the same result as before.

Testing

  • The commit has new fixtures and tests that fail without it.
  • npm run lint, npm run test:coverage, npm run build and tsc --noEmit pass. All 68 tests pass on Node 20, 22 and 24.
  • Values that are not empty or whitespace-only take the same code path as before, so they give the same result.

Part of #279.

🤖 Generated with Claude Code

toSchema() coerced an empty value as if it were set. An empty boolean
value became false, and an empty number value became NaN. SqlClient
reads an empty number value, such as `Connect Timeout=`, as not set,
and uses the default.

toSchema() now gives the schema default for an empty, or whitespace
only, value of a boolean or number key. For example, with MSSQL_SCHEMA,
`Connect Timeout=` now gives 15. The key stays in the result, with the
value `undefined` if the schema has no default. An empty value of a
string key does not change, so an empty password is still an empty
string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhensby
dhensby force-pushed the fix/empty-value-defaults branch from eea22d6 to 2c49b2b Compare November 18, 2026 21:23
@dhensby
dhensby marked this pull request as ready for review November 18, 2026 21:49
@dhensby
dhensby merged commit f87d10c into tediousjs:master Nov 18, 2026
7 checks passed
@dhensby
dhensby deleted the fix/empty-value-defaults branch November 18, 2026 21:49
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.1.2 🎉

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