Skip to content

Commit 05d9f0b

Browse files
ctgbarcalowdhensby
authored andcommitted
feat: add support for driver choice and column encryption in msnodesqlv8 driver
Add the ability to specify config.driver and config.columnEncryption to the msnodesqlv8 driver config.
1 parent b5cf976 commit 05d9f0b

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

.devcontainer/.mssql.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"requestTimeout": 30000,
88
"options": {
99
"abortTransactionOnError": true,
10-
"encrypt": false
10+
"encrypt": false,
11+
"columnEncryption": false
1112
}
1213
}

lib/msnodesqlv8/connection-pool.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ class ConnectionPool extends BaseConnectionPool {
2323

2424
if (!this.config.connectionString) {
2525
cfg.conn_str = buildConnectionString({
26-
Driver: CONNECTION_DRIVER,
26+
Driver: this.config.driver ?? CONNECTION_DRIVER,
2727
Server: this.config.options.instanceName ? `${this.config.server}\\${this.config.instanceName}` : `${this.config.server},${this.config.port}`,
2828
Database: this.config.database,
2929
Uid: this.config.user,
3030
Pwd: this.config.password,
3131
Trusted_Connection: !!this.config.options.trustedConnection,
32-
Encrypt: !!this.config.options.encrypt
32+
Encrypt: !!this.config.options.encrypt,
33+
ColumnEncryption: this.config.columnEncryption ?? 'Disabled'
3334
})
3435
}
3536

test/common/tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,7 @@ module.exports = (sql, driver) => {
13181318
'login failed' (done, message) {
13191319
const config = readConfig()
13201320
config.user = '__notexistinguser__'
1321+
config.options.trustedConnection = false
13211322

13221323
// eslint-disable-next-line no-new
13231324
const conn = new sql.ConnectionPool(config, (err) => {

test/msnodesqlv8/msnodesqlv8.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ describe('msnodesqlv8', function () {
9393
it('request timeout', done => TESTS['request timeout'](done))
9494
it('dataLength type correction', done => TESTS['dataLength type correction'](done))
9595
it('chunked xml support', done => TESTS['chunked xml support'](done))
96+
it('force ODBC connection healthy works', (done) => {
97+
const cfg = config()
98+
cfg.options.driver = 'ODBC Driver 17 for SQL Server'
99+
TESTS['connection healthy works'](cfg, done)
100+
})
96101

97102
after(() => sql.close())
98103
})

0 commit comments

Comments
 (0)