Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for driver choice and col encrypt #1430

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/.mssql.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"requestTimeout": 30000,
"options": {
"abortTransactionOnError": true,
"encrypt": false
"encrypt": false,
"columnEncryption": false
}
}
1 change: 1 addition & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ jobs:
sqlserver-version: ${{ matrix.sqlserver }}
sa-password: ${{ env.MSSQL_PASSWORD }}
native-client-version: 11
odbc-version: 17
- name: Store test config
shell: bash
run: echo "{\"user\":\"sa\",\"password\":\"$MSSQL_PASSWORD\",\"server\":\"localhost\",\"port\":1433,\"database\":\"master\",\"requestTimeout\":30000,\"options\":{\"abortTransactionOnError\":true,\"encrypt\":false}}" > ./test/.mssql.json
Expand Down
5 changes: 3 additions & 2 deletions lib/msnodesqlv8/connection-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ class ConnectionPool extends BaseConnectionPool {

if (!this.config.connectionString) {
cfg.conn_str = buildConnectionString({
Driver: CONNECTION_DRIVER,
Driver: this.config.driver ?? CONNECTION_DRIVER,
Server: this.config.options.instanceName ? `${this.config.server}\\${this.config.options.instanceName}` : `${this.config.server},${this.config.port}`,
Database: this.config.database,
Uid: this.config.user,
Pwd: this.config.password,
Trusted_Connection: !!this.config.options.trustedConnection,
Encrypt: !!this.config.options.encrypt
Encrypt: !!this.config.options.encrypt,
ColumnEncryption: this.config.columnEncryption ?? 'Disabled'
})
}

Expand Down
1 change: 1 addition & 0 deletions test/common/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,7 @@ module.exports = (sql, driver) => {
'login failed' (done, message) {
const config = readConfig()
config.user = '__notexistinguser__'
config.options.trustedConnection = false
dhensby marked this conversation as resolved.
Show resolved Hide resolved

// eslint-disable-next-line no-new
const conn = new sql.ConnectionPool(config, (err) => {
Expand Down
5 changes: 5 additions & 0 deletions test/msnodesqlv8/msnodesqlv8.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ describe('msnodesqlv8', function () {
it('request timeout', done => TESTS['request timeout'](done))
it('dataLength type correction', done => TESTS['dataLength type correction'](done))
it('chunked xml support', done => TESTS['chunked xml support'](done))
it('force ODBC connection healthy works', (done) => {
const cfg = config()
cfg.options.driver = 'ODBC Driver 17 for SQL Server'
TESTS['connection healthy works'](cfg, done)
})

after(() => sql.close())
})
Expand Down