Repository navigation
fix: trim a value before boolean coercion - #301
Merged
Merged
Conversation
The parser keeps the surrounding whitespace of a quoted value. Boolean
coercion then compared the value with `false`, `no` and `0` without
trimming it. So `TrustServerCertificate={ no }` and
`Encrypt=" false "` gave true.
Boolean coercion now trims the value first. SqlClient also trims the
value of its boolean keywords, such as TrustServerCertificate. A quoted
value of only whitespace now gives false, as an empty value does.
Values that are not recognised still give true.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🎉 This PR is included in version 1.1.3 🎉 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.
get(key, 'boolean')now trims a value before it compares it withfalse,noand0. Before, a quoted value with surrounding whitespace, such asTrustServerCertificate={ no }orEncrypt=" false ", gavetrue.Changes
TrustServerCertificate.falseinget(), as an empty value does.toSchema()already gives the schema default for such a value, so its result does not change.get().Values that are not recognised, such as
off, still givetrue. That needs a separate decision.Behaviour changes
Only quoted values with surrounding whitespace change, and they only change from
truetofalse:TrustServerCertificate={ no }now givesfalse, so the certificate is validated.Encrypt=" false "now givesfalse, which is what the value says.Values without surrounding whitespace do not change.
Testing
npm run lint,npm run test:coverage,npm run buildandtsc --noEmitpass. All 70 tests pass on Node 20, 22 and 24.false,no,0or nothing, and every difference goes fromtruetofalse.Part of #279.
🤖 Generated with Claude Code