mssql 7.2.1 → 8.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.txt CHANGED
@@ -1,3 +1,21 @@
1
+ v8.0.0 (2022-01-30)
2
+ -------------------
3
+ [new] Add table.rows.clear() method to allow for chunking updates ([#1094](https://github.com/tediousjs/node-mssql/pull/1094))
4
+ [new] Add valueHandler map to store callbacks that are used to process row values ([#1356](https://github.com/tediousjs/node-mssql/pull/1356))
5
+ [change] msnodesqlv8 driver detects os platform and attempts to pick correct connections string for it ((#1318)[https://github.com/tediousjs/node-mssql/pull/1318])
6
+ [change] Updated to latest Tedious 14 ((#1312)[https://github.com/tediousjs/node-mssql/pull/1312])
7
+ [change] Errors for bad bulk load parameters have slightly different error messages ((#1318)[https://github.com/tediousjs/node-mssql/pull/1318])
8
+ [change] Options provided to the driver via the config.options object will not be overridden with other values if set explicitly ((#1340)[https://github.com/tediousjs/node-mssql/pull/1340])
9
+ [change] Duplicate column names will now be presented as an array even if the values are empty ((#1240)[https://github.com/tediousjs/node-mssql/pull/1240])
10
+ [change] Update tarn pool dependency ((#1344)[https://github.com/tediousjs/node-mssql/pull/1344])
11
+ [removed] Remove connection string parser helpers ((#1342)[https://github.com/tediousjs/node-mssql/pull/1342])
12
+ [removed] Remove deprecated pool properties ((#1359)[https://github.com/tediousjs/node-mssql/pull/1359])
13
+
14
+ v7.3.0 (2021-11-18)
15
+ -------------------
16
+ [new] Transaction/PreparedStatements expose the config from their parent connection
17
+ [fix] Fix inherited request configs from the pool. Specifically stream and arrayRowMode now inherit accurately from the connection config ([#1338](https://github.com/tediousjs/node-mssql/pull/1338))
18
+
1
19
  v7.2.1 (2021-08-19)
2
20
  -------------------
3
21
  [fix] Fix issue with bulk insert of dates ((#1298)[https://github.com/tediousjs/node-mssql/pull/1298])
@@ -44,6 +62,11 @@ v7.0.0 (2021-05-06)
44
62
  [fix] Connection config objects are now deep cloned when stored against a connection pool ([#1217](https://github.com/tediousjs/node-mssql/pull/1217))
45
63
  [removed] Support for connection uri format has been removed (eg: `mssql://user:password@host/?params=values`)
46
64
 
65
+ v6.4.0 (2021-11-18)
66
+ -------------------
67
+ [new] Transaction/PreparedStatements expose the config from their parent connection
68
+ [fix] Fix inherited request configs from the pool. Specifically stream and arrayRowMode now inherit accurately from the connection config ([#1338](https://github.com/tediousjs/node-mssql/pull/1338))
69
+
47
70
  v6.3.2 (2021-05-13)
48
71
  -------------------
49
72
  [fix] Bump various dependencies for security fixes
@@ -247,7 +270,7 @@ v4.0.4 (2017-04-25)
247
270
 
248
271
  v4.0.3 (2017-04-25)
249
272
  -------------------
250
- [fix] Fixed broken CLI & debugging
273
+ [fix] Fixed broken CLI & debugging
251
274
 
252
275
  v4.0.2 (2017-04-19)
253
276
  -------------------
@@ -268,7 +291,7 @@ v4.0.0 (2017-04-01)
268
291
  [change] Removed verbose and debug mode
269
292
  [change] Removed 'driver' from options
270
293
  [change] Removed Transaction and Prepared Statement queues
271
- [change] Removed 'multiple' directive
294
+ [change] Removed 'multiple' directive
272
295
  [change] Connection renamed to ConnectionPool
273
296
  [change] Updated to latest Tedious 2.0.0
274
297
 
package/LICENSE.md CHANGED
@@ -1,22 +1,22 @@
1
- MIT License
2
-
3
- Copyright (c) 2013-2018 Patrik Simek and contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
1
+ MIT License
2
+
3
+ Copyright (c) 2013-2018 Patrik Simek and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md CHANGED
@@ -140,7 +140,7 @@ async () => {
140
140
  * [SQL injection](#sql-injection)
141
141
  * [Known Issues](#known-issues)
142
142
  * [Contributing](https://github.com/tediousjs/node-mssql/wiki/Contributing)
143
- * [6.x to 7.x changes (pre-release)](#6x-to-7x-changes-pre-release)
143
+ * [6.x to 7.x changes](#6x-to-7x-changes)
144
144
  * [5.x to 6.x changes](#5x-to-6x-changes)
145
145
  * [4.x to 5.x changes](#4x-to-5x-changes)
146
146
  * [3.x to 4.x changes](#3x-to-4x-changes)
@@ -370,264 +370,169 @@ function processRows() {
370
370
  }
371
371
  ```
372
372
 
373
- ## Pool Management
374
-
375
- An important concept to understand when using this library is [Connection Pooling](https://en.wikipedia.org/wiki/Connection_pool)
376
- as this library uses connection pooling extensively.
373
+ ## Connection Pools
377
374
 
378
- As one Node JS process is able to handle multiple requests at once, we can take advantage of this long running process
379
- to create a pool of database connections for reuse; this saves overhead of connecting to the database for each request
375
+ An important concept to understand when using this library is [Connection Pooling](https://en.wikipedia.org/wiki/Connection_pool) as this library uses connection pooling extensively. As one Node JS process is able to handle multiple requests at once, we can take advantage of this long running process to create a pool of database connections for reuse; this saves overhead of connecting to the database for each request
380
376
  (as would be the case in something like PHP, where one process handles one request).
381
377
 
382
- With the advantages of pooling comes some added complexities, but these are mostly just conceptual and once you understand
383
- how the pooling is working, it is simple to make use of it efficiently and effectively.
378
+ With the advantages of pooling comes some added complexities, but these are mostly just conceptual and once you understand how the pooling is working, it is simple to make use of it efficiently and effectively.
384
379
 
385
- ### The Global Connection (Pool)
380
+ ### The Global Connection Pool
386
381
 
387
- To assist with pool management in your application there is the global `connect()` function that is available for use. As of
388
- v6 of this library a developer can make repeated calls to this function to obtain the global connection pool. This means you
389
- do not need to keep track of the pool in your application (as used to be the case). If the global pool is already connected,
390
- it will resolve to the connected pool. For example:
382
+ To assist with pool management in your application there is the `sql.connect()` function that is used to connect to the global connection pool. You can make repeated calls to this function, and if the global pool is already connected, it will resolve to the connected pool. The following example obtains the global connection pool by running `sql.connect()`, and then runs the query against the pool.
383
+
384
+ NB: It's important to note that there can only be one global connection pool connected at a time. Providing a different connection config to the `connect()` function will not create a new connection if it is already connected.
391
385
 
392
386
  ```js
393
387
  const sql = require('mssql')
388
+ const config = { ... }
394
389
 
395
390
  // run a query against the global connection pool
396
391
  function runQuery(query) {
397
392
  // sql.connect() will return the existing global pool if it exists or create a new one if it doesn't
398
- return sql.connect().then((pool) => {
393
+ return sql.connect(config).then((pool) => {
399
394
  return pool.query(query)
400
395
  })
401
396
  }
402
-
403
397
  ```
404
398
 
405
- Here we obtain the global connection pool by running `sql.connect()` and we then run the query against the pool.
406
- We also do *not* close the pool after the query is executed and that is because other queries may need to be run against
407
- this pool and closing it will add an overhead to running the query. We should only ever close the pool when our application
408
- is finished. For example, if we are running some kind of CLI tool or a CRON job:
399
+ Awaiting or `.then`-ing the pool creation is a safe way to ensure that the pool is always ready, without knowing where it is needed first. In practice, once the pool is created then there will be no delay for the next `connect()` call.
409
400
 
410
- ```js
411
- const sql = require('mssql')
401
+ Also notice that we do *not* close the global pool by calling `sql.close()` after the query is executed, because other queries may need to be run against this pool and closing it will add additional overhead to running subsequent queries. You should only ever close the global pool if you're certain the application is finished. Or for example, if you are running some kind of CLI tool or a CRON job you can close the pool at the end of the script.
412
402
 
413
- (() => {
414
- sql.connect().then(pool => {
415
- return pool.query('SELECT 1')
416
- }).then(result => {
417
- // do something with result
418
- }).then(() => {
419
- return sql.close()
420
- })
421
- })()
422
- ```
423
-
424
- Here the connection will be closed and the node process will exit once the queries and other application logic has completed.
425
- You should aim to only close the pool once in your application, when it is exiting or you know your application will never make
426
- another SQL query.
403
+ ### Global Pool Single Instance
427
404
 
428
- ### Advanced Pool Management
429
-
430
- In some instances you will not want to use the connection pool, you may have multiple databases to connect to or you may have
431
- one pool for read-only operations and another pool for read-write. In this instance you will need to implement your own pool
432
- management.
405
+ The ability to call `connect()` and `close()` repeatedly on the global pool is intended to make pool management easier, however it is better to maintain your own reference to the pool, where `connect()` is called **once**, and the resulting global pool's connection promise is re-used throughout the entire application.
433
406
 
434
- That could look something like this:
407
+ For example, in Express applications, the following approach uses a single global pool instance added to the `app.locals` so the application has access to it when needed. The server start is then chained inside the `connect()` promise.
435
408
 
436
409
  ```js
437
- const { ConnectionPool } = require('mssql')
438
- const POOLS = {}
439
-
440
- function createPool(config, name) {
441
- if (getPool(name)) {
442
- return Promise.reject(new Error('Pool with this name already exists'))
443
- }
444
- return (new ConnectionPool(config)).connect().then((pool) => {
445
- return POOLS[name] = pool
410
+ const express = require('express')
411
+ const sql = require('mssql')
412
+ const config = {/*...*/}
413
+ //instantiate a connection pool
414
+ const appPool = new sql.ConnectionPool(config)
415
+ //require route handlers and use the same connection pool everywhere
416
+ const route1 = require('./routes/route1')
417
+ const app = express()
418
+ app.get('/path', route1)
419
+
420
+ //connect the pool and start the web server when done
421
+ appPool.connect().then(function(pool) {
422
+ app.locals.db = pool;
423
+ const server = app.listen(3000, function () {
424
+ const host = server.address().address
425
+ const port = server.address().port
426
+ console.log('Example app listening at http://%s:%s', host, port)
446
427
  })
447
- }
448
-
449
- function closePool(name) {
450
- const pool = getPool(name)
451
- if (pool) {
452
- delete POOLS[name]
453
- return pool.close()
454
- }
455
- return Promise.resolve()
456
- }
457
-
458
- function getPool(name) {
459
- if (Object.prototype.hasOwnProperty.apply(POOLS, name)) {
460
- return POOLS[name]
461
- }
462
- }
463
-
464
- module.exports = {
465
- closePool,
466
- createPool,
467
- getPool
468
- }
428
+ }).catch(function(err) {
429
+ console.error('Error creating connection pool', err)
430
+ });
469
431
  ```
470
432
 
471
- This helper file can then be used in your application to create, fetch and close your pools. As with the global pools, you
472
- should aim to only close a pool when you know it will never be needed by the application again; typically this will be when
473
- your application is shutting down.
474
-
475
- ## Connection Pools
476
-
477
- Using a single connection pool for your application/service is recommended.
478
- Instantiating a pool with a callback, or immediately calling `.connect`, is asynchronous to ensure a connection can be
479
- established before returning. From that point, you're able to acquire connections as normal:
480
-
481
- ```javascript
482
- const sql = require('mssql')
433
+ Then the route uses the connection pool in the `app.locals` object:
483
434
 
484
- // async/await style:
485
- const pool1 = new sql.ConnectionPool(config);
486
- const pool1Connect = pool1.connect();
487
-
488
- pool1.on('error', err => {
489
- // ... error handler
490
- })
491
-
492
- async function messageHandler() {
493
- await pool1Connect; // ensures that the pool has been created
494
- try {
495
- const request = pool1.request(); // or: new sql.Request(pool1)
496
- const result = await request.query('select 1 as number')
497
- console.dir(result)
498
- return result;
499
- } catch (err) {
500
- console.error('SQL error', err);
435
+ ```js
436
+ // ./routes/route1.js
437
+ const sql = require('mssql');
438
+
439
+ module.exports = function(req, res) {
440
+ req.locals.db.query('SELECT TOP 10 * FROM table_name', function(err, recordset) {
441
+ if (err) {
442
+ console.error(err)
443
+ res.status(500).send('SERVER ERROR')
444
+ return
501
445
  }
502
- }
503
-
504
- // promise style:
505
- const pool2 = new sql.ConnectionPool(config)
506
- const pool2Connect = pool2.connect()
507
-
508
- pool2.on('error', err => {
509
- // ... error handler
510
- })
511
-
512
- function runStoredProcedure() {
513
- return pool2Connect.then((pool) => {
514
- pool.request() // or: new sql.Request(pool2)
515
- .input('input_parameter', sql.Int, 10)
516
- .output('output_parameter', sql.VarChar(50))
517
- .execute('procedure_name', (err, result) => {
518
- // ... error checks
519
- console.dir(result)
520
- })
521
- }).catch(err => {
522
- // ... error handler
523
- })
446
+ res.status(200).json({ message: 'success' })
447
+ })
524
448
  }
525
449
  ```
526
450
 
527
- Awaiting or `.then`ing the pool creation is a safe way to ensure that the pool is always ready, without knowing where it
528
- is needed first. In practice, once the pool is created then there will be no delay for the next operation.
451
+ ### Advanced Pool Management
529
452
 
530
- As of v6.1.0 you can make repeat calls to `ConnectionPool.connect()` and `ConnectonPool.close()` without an error being
531
- thrown, allowing for the safe use of `mssql.connect().then(...)` throughout your code as well as making multiple calls to
532
- close when your application is shutting down.
453
+ For some use-cases you may want to implement your own connection pool management, rather than using the global connection pool. Reasons for doing this include:
533
454
 
534
- The ability to call `connect()` repeatedly is intended to make pool management easier, however it is still recommended
535
- to follow the example above where `connect()` is called once and using the original resolved connection promise.
536
- Repeatedly calling `connect()` when running queries risks running into problems when `close()` is called on the pool.
455
+ * Supporting connections to multiple databases
456
+ * Creation of separate pools for read vs read/write operations
537
457
 
538
- **ES6 Tagged template literals**
458
+ The following code is an example of a custom connection pool implementation.
539
459
 
540
- ```javascript
541
- new sql.ConnectionPool(config).connect().then(pool => {
542
- return pool.query`select * from mytable where id = ${value}`
543
- }).then(result => {
544
- console.dir(result)
545
- }).catch(err => {
546
- // ... error checks
547
- })
548
- ```
549
-
550
- All values are automatically sanitized against sql injection.
460
+ ```js
461
+ // pool-manager.js
462
+ const mssql = require('mssql')
463
+ const pools = new Map();
551
464
 
552
- ### Managing connection pools
465
+ module.exports = {
466
+ /**
467
+ * Get or create a pool. If a pool doesn't exist the config must be provided.
468
+ * If the pool does exist the config is ignored (even if it was different to the one provided
469
+ * when creating the pool)
470
+ *
471
+ * @param {string} name
472
+ * @param {{}} [config]
473
+ * @return {Promise.<mssql.ConnectionPool>}
474
+ */
475
+ get: (name, config) => {
476
+ if (!pools.has(name)) {
477
+ if (!config) {
478
+ throw new Error('Pool does not exist');
479
+ }
480
+ const pool = new mssql.ConnectionPool(config);
481
+ // automatically remove the pool from the cache if `pool.close()` is called
482
+ const close = pool.close.bind(pool);
483
+ pool.close = (...args) => {
484
+ pools.delete(name);
485
+ return close(...args);
486
+ }
487
+ pools.set(name, pool.connect());
488
+ }
489
+ return pools.get(name);
490
+ },
491
+ /**
492
+ * Closes all the pools and removes them from the store
493
+ *
494
+ * @return {Promise<mssql.ConnectionPool[]>}
495
+ */
496
+ closeAll: () => Promise.all(Array.from(pools.values()).map((connect) => {
497
+ return connect.then((pool) => pool.close());
498
+ })),
499
+ };
500
+ ```
553
501
 
554
- Most applications will only need a single `ConnectionPool` that can be shared throughout the code. To aid the sharing
555
- of a single pool this library exposes a set of functions to access a single global connection. eg:
502
+ This file can then be used in your application to create, fetch, and close pools.
556
503
 
557
504
  ```js
558
- // as part of your application's boot process
505
+ const { get } = require('./pool-manager')
559
506
 
560
- const sql = require('mssql')
561
- const poolPromise = sql.connect()
507
+ async function example() {
508
+ const pool = await get('default')
509
+ return pool.request().query('SELECT 1')
510
+ }
511
+ ```
562
512
 
563
- // during your applications runtime
513
+ Similar to the global connection pool, you should aim to only close a pool when you know it will never be needed by the application again. Typically this will only be when your application is shutting down.
564
514
 
565
- poolPromise.then(() => {
566
- return sql.query('SELECT 1')
567
- }).then(result => {
568
- console.dir(result)
569
- })
515
+ ### Result value manipulation
570
516
 
571
- // when your application exits
572
- poolPromise.then(() => {
573
- return sql.close()
574
- })
575
- ```
517
+ In some instances it is desirable to manipulate the record data as it is returned from the database, this may be to cast it as a particular object (eg: `moment` object instead of `Date`) or similar.
576
518
 
577
- If you require multiple pools per application (perhaps you have many DBs you need to connect to or you want a read-only
578
- pool), then you will need to manage your pools yourself. The best way to do this is to create a shared library file that
579
- can hold references to the pools for you. For example:
519
+ In v8.0.0+ it is possible to register per-datatype handlers:
580
520
 
581
521
  ```js
582
522
  const sql = require('mssql')
583
523
 
584
- const pools = {}
585
-
586
- // manage a set of pools by name (config will be required to create the pool)
587
- // a pool will be removed when it is closed
588
- async function getPool(name, config) {
589
- if (!Object.prototype.hasOwnProperty.call(pools, name)) {
590
- const pool = new sql.ConnectionPool(config)
591
- const close = pool.close.bind(pool)
592
- pool.close = (...args) => {
593
- delete pools[name]
594
- return close(...args)
595
- }
596
- await pool.connect()
597
- pools[name] = pool
598
- }
599
- return pools[name]
600
- }
601
-
602
- // close all pools
603
- function closeAll() {
604
- return Promise.all(Object.values(pools).map((pool) => {
605
- return pool.close()
606
- }))
607
- }
608
-
609
- module.exports = {
610
- closeAll,
611
- getPool
612
- }
613
- ```
614
-
615
- You can then use this library file in your code to get a connected pool when you need it:
524
+ // in this example all integer values will return 1 more than their actual value in the database
525
+ sql.valueHandler.set(sql.TYPES.Int, (value) => value + 1)
616
526
 
617
- ```js
618
- const { getPool } = require('./path/to/file')
619
-
620
- // run a query
621
- async function runQuery(query, config) {
622
- // pool will always be connected when the promise has resolved - may reject if the connection config is invalid
623
- const pool = await getPool('default', config)
624
- const result = await pool.request().query(query)
625
- return result
626
- }
527
+ sql.query('SELECT * FROM [example]').then((result) => {
528
+ // all `int` columns will return a manipulated value as per the callback above
529
+ })
627
530
  ```
628
531
 
629
532
  ## Configuration
630
533
 
534
+ The following is an example configuration object:
535
+
631
536
  ```javascript
632
537
  const config = {
633
538
  user: '...',
@@ -1616,6 +1521,20 @@ request.execute('MyCustomStoredProcedure', (err, result) => {
1616
1521
 
1617
1522
  **TIP**: You can also create Table variable from any recordset with `recordset.toTable()`. You can optionally specify table type name in the first argument.
1618
1523
 
1524
+ You can clear the table rows for easier batching by using `table.rows.clear()`
1525
+
1526
+ ```js
1527
+ const tvp = new sql.Table() // You can optionally specify table type name in the first argument.
1528
+
1529
+ // Columns must correspond with type we have created in database.
1530
+ tvp.columns.add('a', sql.VarChar(50))
1531
+ tvp.columns.add('b', sql.Int)
1532
+
1533
+ // Add rows
1534
+ tvp.rows.add('hello tvp', 777) // Values are in same order as columns.
1535
+ tvp.rows.clear()
1536
+ ```
1537
+
1619
1538
  ## Response Schema
1620
1539
 
1621
1540
  An object returned from a `sucessful` basic query would look like the following.
@@ -2094,11 +2013,20 @@ request.query('select @myval as myval', (err, result) => {
2094
2013
  - If you're facing problems with connecting SQL Server 2000, try setting the default TDS version to 7.1 with `config.options.tdsVersion = '7_1'` ([issue](https://github.com/tediousjs/node-mssql/issues/36))
2095
2014
  - If you're executing a statement longer than 4000 chars on SQL Server 2000, always use [batch](#batch-batch-callback) instead of [query](#query-command-callback) ([issue](https://github.com/tediousjs/node-mssql/issues/68))
2096
2015
 
2097
- ## 6.x to 7.x changes (pre-release)
2016
+ ## 7.x to 8.x changes
2017
+
2018
+ - Upgraded to tedious version 14
2019
+ - Removed internal library for connection string parsing. Connection strings can be resolved using the static method `parseConnectionString` on ConnectionPool
2020
+
2021
+ ## 6.x to 7.x changes
2098
2022
 
2099
- - Upgraded tedious version to v8
2023
+ - Upgraded tedious version to v11
2024
+ - Upgraded msnodesqlv8 version support to v2
2025
+ - Upgraded tarn.js version to v3
2100
2026
  - Requests in stream mode that pipe into other streams no longer pass errors up the stream chain
2027
+ - Request.pipe now pipes a true node stream for better support of backpressure
2101
2028
  - tedious config option `trustServerCertificate` defaults to `false` if not supplied
2029
+ - Dropped support for Node < 10
2102
2030
 
2103
2031
  ## 5.x to 6.x changes
2104
2032
 
package/bin/mssql CHANGED
File without changes
@@ -7,7 +7,7 @@ const tarn = require('tarn')
7
7
  const { IDS } = require('../utils')
8
8
  const ConnectionError = require('../error/connection-error')
9
9
  const shared = require('../shared')
10
- const deepclone = require('rfdc/default')
10
+ const clone = require('rfdc/default')
11
11
 
12
12
  /**
13
13
  * Class ConnectionPool.
@@ -44,7 +44,7 @@ class ConnectionPool extends EventEmitter {
44
44
 
45
45
  if (typeof config === 'string') {
46
46
  try {
47
- this.config = this.parseConnectionString(config)
47
+ this.config = this.constructor.parseConnectionString(config)
48
48
  } catch (ex) {
49
49
  if (typeof callback === 'function') {
50
50
  return setImmediate(callback, ex)
@@ -52,7 +52,7 @@ class ConnectionPool extends EventEmitter {
52
52
  throw ex
53
53
  }
54
54
  } else {
55
- this.config = deepclone(config)
55
+ this.config = clone(config)
56
56
  }
57
57
 
58
58
  // set defaults
@@ -85,11 +85,11 @@ class ConnectionPool extends EventEmitter {
85
85
  return this._healthy
86
86
  }
87
87
 
88
- parseConnectionString (connectionString) {
88
+ static parseConnectionString (connectionString) {
89
89
  return this._parseConnectionString(connectionString)
90
90
  }
91
91
 
92
- _parseConnectionString (connectionString) {
92
+ static _parseConnectionString (connectionString) {
93
93
  const parsed = parseSqlConnectionString(connectionString, true, true)
94
94
  return Object.entries(parsed).reduce((config, [key, value]) => {
95
95
  switch (key) {
@@ -388,41 +388,6 @@ class ConnectionPool extends EventEmitter {
388
388
  propagateCreateError: true
389
389
  }, this.config.pool)
390
390
  )
391
- const self = this
392
- Object.defineProperties(this.pool, {
393
- size: {
394
- get: () => {
395
- const message = 'the `size` property on pool is deprecated, access it directly on the `ConnectionPool`'
396
- self.emit('debug', message)
397
- process.emitWarning(message)
398
- return self.size
399
- }
400
- },
401
- available: {
402
- get: () => {
403
- const message = 'the `available` property on pool is deprecated, access it directly on the `ConnectionPool`'
404
- self.emit('debug', message)
405
- process.emitWarning(message)
406
- return self.available
407
- }
408
- },
409
- pending: {
410
- get: () => {
411
- const message = 'the `pending` property on pool is deprecate, access it directly on the `ConnectionPool`'
412
- self.emit('debug', message)
413
- process.emitWarning(message)
414
- return self.pending
415
- }
416
- },
417
- borrowed: {
418
- get: () => {
419
- const message = 'the `borrowed` property on pool is deprecated, access it directly on the `ConnectionPool`'
420
- self.emit('debug', message)
421
- process.emitWarning(message)
422
- return self.borrowed
423
- }
424
- }
425
- })
426
391
 
427
392
  this._connecting = false
428
393
  this._connected = true
package/lib/base/index.js CHANGED
@@ -54,6 +54,13 @@ Object.defineProperty(module.exports, 'Promise', {
54
54
  }
55
55
  })
56
56
 
57
+ Object.defineProperty(module.exports, 'valueHandler', {
58
+ enumerable: true,
59
+ value: shared.valueHandler,
60
+ writable: false,
61
+ configurable: false
62
+ })
63
+
57
64
  for (const key in TYPES) {
58
65
  const value = TYPES[key]
59
66
  module.exports.exports[key] = value
@@ -35,6 +35,10 @@ class PreparedStatement extends EventEmitter {
35
35
  this.parameters = {}
36
36
  }
37
37
 
38
+ get config () {
39
+ return this.parent.config
40
+ }
41
+
38
42
  get connected () {
39
43
  return this.parent.connected
40
44
  }