Found while reviewing how node-mssql consumes this package (1.1.0; the same code is on master).
1. An empty unquoted value absorbs the next Key=Value pair.
parse('TrustServerCertificate=;Encrypt=true;Server=h') gives { trustservercertificate: ';Encrypt=true', server: 'h' }. The Encrypt key is lost and the empty value becomes ;Encrypt=true. The quoted form TrustServerCertificate="";Encrypt=true;Server=h parses correctly, so this is specific to the unstarted/unquoted branch (connection-string-parser.ts: the !started path pushes the first non-whitespace character without checking isTerminator). Templates rendered with an unset variable hit this.
Expected: { trustservercertificate: '', encrypt: 'true', server: 'h' }.
2. build() treats a value that starts with { and ends with } as already quoted.
build({ Pwd: '{a}' }) gives Pwd={a}, and parse() of that gives a, so a literal value {a} cannot round-trip. Expected Pwd={{a}}}, or an explicit per-key way to pass a pre-quoted value such as Driver={ODBC Driver 18 for SQL Server}, which is presumably what the heuristic exists for.
3. needsQuotes misses a bare (.
The regex alternative \|\( matches the two-character sequence |(, not (: build({ Pwd: 'a(b' }) gives Pwd=a(b while build({ Pwd: 'a|(b' }) is quoted. Also, } inside a quoted value is emitted as }}, which is the SqlClient convention; the ODBC SQLDriverConnect grammar does not define an escape for } inside braces, so it may be worth documenting which dialect build() targets.
4. Unknown boolean values coerce to true.
The schema coerces anything outside false/no/0 to true, so TrustServerCertificate=off or a typo becomes true, and Encrypt=strict loses its meaning. ADO.NET's SqlConnectionStringBuilder and the ODBC driver reject unrecognised boolean values; consider throwing, or keeping the raw string for keys that accept more than two values.
Happy to send PRs for 1 to 3 if that helps.
Found while reviewing how node-mssql consumes this package (1.1.0; the same code is on
master).1. An empty unquoted value absorbs the next
Key=Valuepair.parse('TrustServerCertificate=;Encrypt=true;Server=h')gives{ trustservercertificate: ';Encrypt=true', server: 'h' }. TheEncryptkey is lost and the empty value becomes;Encrypt=true. The quoted formTrustServerCertificate="";Encrypt=true;Server=hparses correctly, so this is specific to the unstarted/unquoted branch (connection-string-parser.ts: the!startedpath pushes the first non-whitespace character without checkingisTerminator). Templates rendered with an unset variable hit this.Expected:
{ trustservercertificate: '', encrypt: 'true', server: 'h' }.2.
build()treats a value that starts with{and ends with}as already quoted.build({ Pwd: '{a}' })givesPwd={a}, andparse()of that givesa, so a literal value{a}cannot round-trip. ExpectedPwd={{a}}}, or an explicit per-key way to pass a pre-quoted value such asDriver={ODBC Driver 18 for SQL Server}, which is presumably what the heuristic exists for.3.
needsQuotesmisses a bare(.The regex alternative
\|\(matches the two-character sequence|(, not(:build({ Pwd: 'a(b' })givesPwd=a(bwhilebuild({ Pwd: 'a|(b' })is quoted. Also,}inside a quoted value is emitted as}}, which is the SqlClient convention; the ODBCSQLDriverConnectgrammar does not define an escape for}inside braces, so it may be worth documenting which dialectbuild()targets.4. Unknown boolean values coerce to
true.The schema coerces anything outside
false/no/0totrue, soTrustServerCertificate=offor a typo becomestrue, andEncrypt=strictloses its meaning. ADO.NET'sSqlConnectionStringBuilderand the ODBC driver reject unrecognised boolean values; consider throwing, or keeping the raw string for keys that accept more than two values.Happy to send PRs for 1 to 3 if that helps.