tediousjs / node-mssql

Microsoft SQL Server client for Node.js
https://tediousjs.github.io/node-mssql
MIT License
2.23k stars 467 forks source link

Error in connecting to database when using msnodesqlv8 driver and password has special character in it #1476

Closed abhku closed 1 year ago

abhku commented 1 year ago

I am using mssql with msnodesqlv8. I have database with password containing ; in it e.g. -'%;0&<,4#l} . SQL server allows password like this but when we use this kind of password the ODBC connection string doesn't works and gives Error : Login failed for user 'xxxx'.,Error: [Microsoft][SQL Server Native Client 11.0]Invalid connection string attribute

Expected behaviour:

Connection should work

Actual behaviour:

Connection is not working

Configuration:

{
  options: {
    instanceName: undefined,
    trustServerCertificate: false,
    abortTransactionOnError: true
  },
  pool: { max: 100, min: 1, idleTimeoutMillis: 50 },
  port: 1433,
  server: 'xxxxxxx',
  database: 'xxxxx',
  domain: undefined,
  user: 'xxxxx',
  password: "-'%;0&<,4#l}",
  connectionTimeout: 30000,
  requestTimeout: 120000
}

Software versions

abhku commented 1 year ago

The password should be wrapped within {} and escape } with }}

dhensby commented 1 year ago

Interesting, that's a good catch - the way msnodesqlv8 works is that we provide an SQL connection string to it, and we should be escaping special chars when we construct that string which, clearly, is not happening...

dhensby commented 1 year ago

I've tried to fix this in #1479 - can you take a look and let me know if it fixes your problem

abhku commented 1 year ago

Yes, this fixes the problem

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 9.1.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: