tedious 6.4.0 → 6.6.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.
Files changed (86) hide show
  1. package/lib/bulk-load.js +17 -22
  2. package/lib/connection.js +363 -251
  3. package/lib/connector.js +3 -1
  4. package/lib/data-type.js +111 -109
  5. package/lib/data-types/bigint.js +19 -7
  6. package/lib/data-types/binary.js +19 -10
  7. package/lib/data-types/bit.js +14 -4
  8. package/lib/data-types/bitn.js +26 -3
  9. package/lib/data-types/char.js +26 -13
  10. package/lib/data-types/date.js +18 -9
  11. package/lib/data-types/datetime.js +23 -5
  12. package/lib/data-types/datetime2.js +10 -22
  13. package/lib/data-types/datetimen.js +26 -3
  14. package/lib/data-types/datetimeoffset.js +11 -22
  15. package/lib/data-types/decimal.js +14 -6
  16. package/lib/data-types/decimaln.js +26 -5
  17. package/lib/data-types/float.js +14 -4
  18. package/lib/data-types/floatn.js +26 -3
  19. package/lib/data-types/image.js +12 -5
  20. package/lib/data-types/int.js +14 -4
  21. package/lib/data-types/intn.js +26 -3
  22. package/lib/data-types/money.js +14 -4
  23. package/lib/data-types/moneyn.js +26 -3
  24. package/lib/data-types/nchar.js +17 -6
  25. package/lib/data-types/ntext.js +26 -5
  26. package/lib/data-types/null.js +27 -3
  27. package/lib/data-types/numeric.js +14 -6
  28. package/lib/data-types/numericn.js +26 -5
  29. package/lib/data-types/nvarchar.js +20 -11
  30. package/lib/data-types/real.js +14 -4
  31. package/lib/data-types/smalldatetime.js +14 -4
  32. package/lib/data-types/smallint.js +14 -4
  33. package/lib/data-types/smallmoney.js +14 -4
  34. package/lib/data-types/sql-variant.js +23 -4
  35. package/lib/data-types/text.js +13 -7
  36. package/lib/data-types/time.js +9 -21
  37. package/lib/data-types/tinyint.js +14 -4
  38. package/lib/data-types/tvp.js +12 -3
  39. package/lib/data-types/udt.js +26 -3
  40. package/lib/data-types/uniqueidentifier.js +12 -5
  41. package/lib/data-types/varbinary.js +18 -8
  42. package/lib/data-types/varchar.js +19 -10
  43. package/lib/data-types/xml.js +26 -3
  44. package/lib/debug.js +3 -1
  45. package/lib/guid-parser.js +6 -6
  46. package/lib/incoming-message-stream.js +10 -7
  47. package/lib/instance-lookup.js +12 -6
  48. package/lib/library.js +6 -1
  49. package/lib/login7-payload.js +2 -3
  50. package/lib/message-io.js +14 -3
  51. package/lib/message.js +2 -3
  52. package/lib/metadata-parser.js +259 -136
  53. package/lib/ntlm-payload.js +12 -21
  54. package/lib/outgoing-message-stream.js +7 -6
  55. package/lib/packet.js +4 -5
  56. package/lib/prelogin-payload.js +3 -4
  57. package/lib/request.js +11 -11
  58. package/lib/rpcrequest-payload.js +28 -22
  59. package/lib/sender.js +25 -11
  60. package/lib/special-stored-procedure.js +9 -2
  61. package/lib/tds-versions.js +8 -2
  62. package/lib/tedious.js +75 -9
  63. package/lib/token/colmetadata-token-parser.js +20 -10
  64. package/lib/token/done-token-parser.js +32 -25
  65. package/lib/token/env-change-token-parser.js +50 -20
  66. package/lib/token/feature-ext-ack-parser.js +19 -14
  67. package/lib/token/fedauth-info-parser.js +17 -11
  68. package/lib/token/infoerror-token-parser.js +14 -14
  69. package/lib/token/loginack-token-parser.js +21 -12
  70. package/lib/token/nbcrow-token-parser.js +35 -23
  71. package/lib/token/order-token-parser.js +14 -7
  72. package/lib/token/returnstatus-token-parser.js +14 -7
  73. package/lib/token/returnvalue-token-parser.js +22 -11
  74. package/lib/token/row-token-parser.js +34 -22
  75. package/lib/token/sspi-token-parser.js +14 -8
  76. package/lib/token/stream-parser.js +95 -36
  77. package/lib/token/token-stream-parser.js +16 -10
  78. package/lib/token/token.js +396 -2
  79. package/lib/tracking-buffer/writable-tracking-buffer.js +37 -5
  80. package/lib/transaction.js +25 -16
  81. package/lib/transient-error-lookup.js +6 -1
  82. package/lib/value-parser.js +412 -315
  83. package/package.json +24 -21
  84. package/pull_request_template.md +1 -1
  85. package/tsconfig.json +1 -1
  86. package/lib/tracking-buffer/bigint.js +0 -102
package/lib/bulk-load.js CHANGED
@@ -9,18 +9,17 @@ var _events = require("events");
9
9
 
10
10
  var _writableTrackingBuffer = _interopRequireDefault(require("./tracking-buffer/writable-tracking-buffer"));
11
11
 
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ var _readableStream = require("readable-stream");
13
13
 
14
- const Transform = require('readable-stream').Transform;
14
+ var _token = require("./token/token");
15
15
 
16
- const TOKEN_TYPE = require('./token/token').TYPE;
16
+ var _message = _interopRequireDefault(require("./message"));
17
17
 
18
- const Message = require('./message');
18
+ var _packet = require("./packet");
19
19
 
20
- const PACKET_TYPE = require('./packet').TYPE;
20
+ var _errors = require("./errors");
21
21
 
22
- const _require = require('./errors'),
23
- RequestError = _require.RequestError;
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
23
 
25
24
  const FLAGS = {
26
25
  nullable: 1 << 0,
@@ -129,16 +128,12 @@ class BulkLoad extends _events.EventEmitter {
129
128
  }
130
129
  }
131
130
 
132
- if (type.hasPrecision) {
133
- if (column.precision == null && type.resolvePrecision) {
134
- column.precision = type.resolvePrecision(column);
135
- }
131
+ if (type.resolvePrecision && column.precision == null) {
132
+ column.precision = type.resolvePrecision(column);
136
133
  }
137
134
 
138
- if (type.hasScale) {
139
- if (column.scale == null && type.resolveScale) {
140
- column.scale = type.resolveScale(column);
141
- }
135
+ if (type.resolveScale && column.scale == null) {
136
+ column.scale = type.resolveScale(column);
142
137
  }
143
138
 
144
139
  this.columns.push(column);
@@ -234,7 +229,7 @@ class BulkLoad extends _events.EventEmitter {
234
229
  getColMetaData() {
235
230
  const tBuf = new _writableTrackingBuffer.default(100, null, true); // TokenType
236
231
 
237
- tBuf.writeUInt8(TOKEN_TYPE.COLMETADATA); // Count
232
+ tBuf.writeUInt8(_token.TYPE.COLMETADATA); // Count
238
233
 
239
234
  tBuf.writeUInt16LE(this.columns.length);
240
235
 
@@ -273,7 +268,7 @@ class BulkLoad extends _events.EventEmitter {
273
268
  createDoneToken() {
274
269
  // It might be nice to make DoneToken a class if anything needs to create them, but for now, just do it here
275
270
  const tBuf = new _writableTrackingBuffer.default(this.options.tdsVersion < '7_2' ? 9 : 13);
276
- tBuf.writeUInt8(TOKEN_TYPE.DONE);
271
+ tBuf.writeUInt8(_token.TYPE.DONE);
277
272
  const status = DONE_STATUS.FINAL;
278
273
  tBuf.writeUInt16LE(status);
279
274
  tBuf.writeUInt16LE(0); // CurCmd (TDS ignores this)
@@ -303,8 +298,8 @@ class BulkLoad extends _events.EventEmitter {
303
298
  }
304
299
 
305
300
  getMessageStream() {
306
- const message = new Message({
307
- type: PACKET_TYPE.BULK_LOAD
301
+ const message = new _message.default({
302
+ type: _packet.TYPE.BULK_LOAD
308
303
  });
309
304
  this.rowToPacketTransform.pipe(message);
310
305
  this.rowToPacketTransform.once('finish', () => {
@@ -312,7 +307,7 @@ class BulkLoad extends _events.EventEmitter {
312
307
  });
313
308
 
314
309
  const onCancel = () => {
315
- this.rowToPacketTransform.emit('error', RequestError('Canceled.', 'ECANCEL'));
310
+ this.rowToPacketTransform.emit('error', (0, _errors.RequestError)('Canceled.', 'ECANCEL'));
316
311
  this.rowToPacketTransform.destroy();
317
312
  };
318
313
 
@@ -335,7 +330,7 @@ var _default = BulkLoad;
335
330
  exports.default = _default;
336
331
  module.exports = BulkLoad; // A transform that converts rows to packets.
337
332
 
338
- class RowTransform extends Transform {
333
+ class RowTransform extends _readableStream.Transform {
339
334
  constructor(bulkLoad) {
340
335
  super({
341
336
  writableObjectMode: true
@@ -353,7 +348,7 @@ class RowTransform extends Transform {
353
348
  }
354
349
 
355
350
  const buf = new _writableTrackingBuffer.default(64, 'ucs2', true);
356
- buf.writeUInt8(TOKEN_TYPE.ROW);
351
+ buf.writeUInt8(_token.TYPE.ROW);
357
352
 
358
353
  for (let i = 0; i < this.columns.length; i++) {
359
354
  const c = this.columns[i];