tedious 1.13.2 → 1.14.0

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 (46) hide show
  1. package/appveyor.yml +2 -0
  2. package/lib/all-headers.js +2 -5
  3. package/lib/buffertools.js +1 -1
  4. package/lib/bulk-load.js +18 -27
  5. package/lib/collation.js +78 -6
  6. package/lib/connection.js +120 -159
  7. package/lib/data-type.js +73 -72
  8. package/lib/debug.js +5 -17
  9. package/lib/errors.js +8 -16
  10. package/lib/guid-parser.js +2 -5
  11. package/lib/instance-lookup.js +7 -16
  12. package/lib/library.js +1 -5
  13. package/lib/login7-payload.js +16 -34
  14. package/lib/message-io.js +21 -35
  15. package/lib/metadata-parser.js +22 -18
  16. package/lib/ntlm-payload.js +9 -24
  17. package/lib/packet.js +11 -18
  18. package/lib/prelogin-payload.js +10 -19
  19. package/lib/request.js +15 -24
  20. package/lib/rpcrequest-payload.js +7 -16
  21. package/lib/special-stored-procedure.js +3 -7
  22. package/lib/sqlbatch-payload.js +7 -16
  23. package/lib/stream-parser.js +24 -36
  24. package/lib/tds-versions.js +2 -8
  25. package/lib/tedious.js +8 -52
  26. package/lib/token/colmetadata-token-parser.js +4 -14
  27. package/lib/token/done-token-parser.js +6 -9
  28. package/lib/token/env-change-token-parser.js +4 -9
  29. package/lib/token/infoerror-token-parser.js +9 -12
  30. package/lib/token/loginack-token-parser.js +8 -8
  31. package/lib/token/nbcrow-token-parser.js +5 -15
  32. package/lib/token/order-token-parser.js +3 -9
  33. package/lib/token/returnstatus-token-parser.js +3 -9
  34. package/lib/token/returnvalue-token-parser.js +7 -20
  35. package/lib/token/row-token-parser.js +5 -15
  36. package/lib/token/sspi-token-parser.js +3 -8
  37. package/lib/token/stream-parser.js +60 -58
  38. package/lib/token/token-stream-parser.js +14 -23
  39. package/lib/token/token.js +3 -7
  40. package/lib/tracking-buffer/bigint.js +2 -5
  41. package/lib/tracking-buffer/readable-tracking-buffer.js +6 -13
  42. package/lib/tracking-buffer/tracking-buffer.js +2 -16
  43. package/lib/tracking-buffer/writable-tracking-buffer.js +3 -15
  44. package/lib/transaction.js +7 -12
  45. package/lib/value-parser.js +95 -69
  46. package/package.json +6 -1
package/appveyor.yml CHANGED
@@ -5,11 +5,13 @@ environment:
5
5
  - nodejs_version: "0.10"
6
6
  - nodejs_version: "0.12"
7
7
  - nodejs_version: "4"
8
+ - nodejs_version: "5"
8
9
 
9
10
  branches:
10
11
  only:
11
12
  - master
12
13
  - /^maint\/.+/
14
+ - /v\d+\.\d+\.\d+/
13
15
 
14
16
  install:
15
17
  - ps: Install-Product node $env:nodejs_version
@@ -1,9 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.writeToTrackingBuffer = writeToTrackingBuffer;
7
3
  var TYPE = {
8
4
  QUERY_NOTIFICATIONS: 1,
9
5
  TXN_DESCRIPTOR: 2,
@@ -14,6 +10,7 @@ var TXNDESCRIPTOR_HEADER_DATA_LEN = 4 + 8;
14
10
 
15
11
  var TXNDESCRIPTOR_HEADER_LEN = 4 + 2 + TXNDESCRIPTOR_HEADER_DATA_LEN;
16
12
 
13
+ module.exports.writeToTrackingBuffer = writeToTrackingBuffer;
17
14
  function writeToTrackingBuffer(buffer, txnDescriptor, outstandingRequestCount) {
18
15
  buffer.writeUInt32LE(0);
19
16
  buffer.writeUInt32LE(TXNDESCRIPTOR_HEADER_LEN);
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  if (!Buffer.concat) {
4
4
  Buffer.concat = function (buffers) {
package/lib/bulk-load.js CHANGED
@@ -8,15 +8,9 @@ var _createClass = require('babel-runtime/helpers/create-class')['default'];
8
8
 
9
9
  var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
10
10
 
11
- Object.defineProperty(exports, '__esModule', {
12
- value: true
13
- });
14
-
15
- var _events = require('events');
16
-
17
- var _trackingBufferTrackingBuffer = require('./tracking-buffer/tracking-buffer');
18
-
19
- var _tokenToken = require('./token/token');
11
+ var EventEmitter = require('events').EventEmitter;
12
+ var WritableTrackingBuffer = require('./tracking-buffer/tracking-buffer').WritableTrackingBuffer;
13
+ var TOKEN_TYPE = require('./token/token').TYPE;
20
14
 
21
15
  var FLAGS = {
22
16
  nullable: 1 << 0,
@@ -42,7 +36,7 @@ var DONE_STATUS = {
42
36
  SRVERROR: 0x100
43
37
  };
44
38
 
45
- var BulkLoad = (function (_EventEmitter) {
39
+ module.exports = (function (_EventEmitter) {
46
40
  _inherits(BulkLoad, _EventEmitter);
47
41
 
48
42
  function BulkLoad(table, options1, callback) {
@@ -58,7 +52,7 @@ var BulkLoad = (function (_EventEmitter) {
58
52
  this.callback = callback;
59
53
  this.columns = [];
60
54
  this.columnsByName = {};
61
- this.rowsData = new _trackingBufferTrackingBuffer.WritableTrackingBuffer(1024, 'ucs2', true);
55
+ this.rowsData = new WritableTrackingBuffer(1024, 'ucs2', true);
62
56
  this.firstRowWritten = false;
63
57
  }
64
58
 
@@ -123,7 +117,7 @@ var BulkLoad = (function (_EventEmitter) {
123
117
  }
124
118
 
125
119
  // write row token
126
- this.rowsData.writeUInt8(_tokenToken.TYPE.ROW);
120
+ this.rowsData.writeUInt8(TOKEN_TYPE.ROW);
127
121
 
128
122
  // write each column
129
123
  var arr = row instanceof Array;
@@ -146,7 +140,7 @@ var BulkLoad = (function (_EventEmitter) {
146
140
  if (i !== 0) {
147
141
  sql += ', ';
148
142
  }
149
- sql += "[" + c.name + "] " + c.type.declaration(c);
143
+ sql += '[' + c.name + '] ' + c.type.declaration(c);
150
144
  }
151
145
  sql += ')';
152
146
  return sql;
@@ -160,9 +154,9 @@ var BulkLoad = (function (_EventEmitter) {
160
154
  if (i !== 0) {
161
155
  sql += ',\n';
162
156
  }
163
- sql += "[" + c.name + "] " + c.type.declaration(c);
157
+ sql += '[' + c.name + '] ' + c.type.declaration(c);
164
158
  if (c.nullable !== void 0) {
165
- sql += " " + (c.nullable ? "NULL" : "NOT NULL");
159
+ sql += ' ' + (c.nullable ? 'NULL' : 'NOT NULL');
166
160
  }
167
161
  }
168
162
  sql += '\n)';
@@ -181,13 +175,13 @@ var BulkLoad = (function (_EventEmitter) {
181
175
 
182
176
  // Create DONE token
183
177
  // It might be nice to make DoneToken a class if anything needs to create them, but for now, just do it here
184
- var tBuf = new _trackingBufferTrackingBuffer.WritableTrackingBuffer(this.options.tdsVersion < "7_2" ? 9 : 13);
185
- tBuf.writeUInt8(_tokenToken.TYPE.DONE);
178
+ var tBuf = new WritableTrackingBuffer(this.options.tdsVersion < '7_2' ? 9 : 13);
179
+ tBuf.writeUInt8(TOKEN_TYPE.DONE);
186
180
  var status = DONE_STATUS.FINAL;
187
181
  tBuf.writeUInt16LE(status);
188
182
  tBuf.writeUInt16LE(0); // CurCmd (TDS ignores this)
189
183
  tBuf.writeUInt32LE(0); // row count - doesn't really matter
190
- if (this.options.tdsVersion >= "7_2") {
184
+ if (this.options.tdsVersion >= '7_2') {
191
185
  tBuf.writeUInt32LE(0); // row count is 64 bits in >= TDS 7.2
192
186
  }
193
187
 
@@ -195,7 +189,7 @@ var BulkLoad = (function (_EventEmitter) {
195
189
  length += done.length;
196
190
 
197
191
  // composite payload
198
- var payload = new _trackingBufferTrackingBuffer.WritableTrackingBuffer(length);
192
+ var payload = new WritableTrackingBuffer(length);
199
193
  payload.copyFrom(metaData);
200
194
  payload.copyFrom(rows);
201
195
  payload.copyFrom(done);
@@ -204,16 +198,16 @@ var BulkLoad = (function (_EventEmitter) {
204
198
  }, {
205
199
  key: 'getColMetaData',
206
200
  value: function getColMetaData() {
207
- var tBuf = new _trackingBufferTrackingBuffer.WritableTrackingBuffer(100, null, true);
201
+ var tBuf = new WritableTrackingBuffer(100, null, true);
208
202
  // TokenType
209
- tBuf.writeUInt8(_tokenToken.TYPE.COLMETADATA);
203
+ tBuf.writeUInt8(TOKEN_TYPE.COLMETADATA);
210
204
  // Count
211
205
  tBuf.writeUInt16LE(this.columns.length);
212
206
 
213
207
  for (var j = 0, len = this.columns.length; j < len; j++) {
214
208
  var c = this.columns[j];
215
209
  // UserType
216
- if (this.options.tdsVersion < "7_2") {
210
+ if (this.options.tdsVersion < '7_2') {
217
211
  tBuf.writeUInt16LE(0);
218
212
  } else {
219
213
  tBuf.writeUInt32LE(0);
@@ -223,7 +217,7 @@ var BulkLoad = (function (_EventEmitter) {
223
217
  var flags = FLAGS.updateableReadWrite;
224
218
  if (c.nullable) {
225
219
  flags |= FLAGS.nullable;
226
- } else if (c.nullable === void 0 && this.options.tdsVersion >= "7_2") {
220
+ } else if (c.nullable === void 0 && this.options.tdsVersion >= '7_2') {
227
221
  flags |= FLAGS.nullableUnknown;
228
222
  }
229
223
  tBuf.writeUInt16LE(flags);
@@ -239,7 +233,4 @@ var BulkLoad = (function (_EventEmitter) {
239
233
  }]);
240
234
 
241
235
  return BulkLoad;
242
- })(_events.EventEmitter);
243
-
244
- exports['default'] = BulkLoad;
245
- module.exports = exports['default'];
236
+ })(EventEmitter);
package/lib/collation.js CHANGED
@@ -1,10 +1,7 @@
1
- // http://technet.microsoft.com/en-us/library/aa176553(v=sql.80).aspx
2
1
  'use strict';
3
2
 
4
- Object.defineProperty(exports, '__esModule', {
5
- value: true
6
- });
7
- var codepageByLcid = {
3
+ // http://technet.microsoft.com/en-us/library/aa176553(v=sql.80).aspx
4
+ module.exports.codepageByLcid = {
8
5
  0x436: 'CP1252',
9
6
  0x401: 'CP1256',
10
7
  0x801: 'CP1256',
@@ -111,4 +108,79 @@ var codepageByLcid = {
111
108
  0x420: 'CP1256',
112
109
  0x42A: 'CP1258'
113
110
  };
114
- exports.codepageByLcid = codepageByLcid;
111
+
112
+ module.exports.codepageBySortId = {
113
+ 30: 'CP437', // SQL_Latin1_General_CP437_BIN
114
+ 31: 'CP437', // SQL_Latin1_General_CP437_CS_AS
115
+ 32: 'CP437', // SQL_Latin1_General_CP437_CI_AS
116
+ 33: 'CP437', // SQL_Latin1_General_Pref_CP437_CI_AS
117
+ 34: 'CP437', // SQL_Latin1_General_CP437_CI_AI
118
+ 40: 'CP850', // SQL_Latin1_General_CP850_BIN
119
+ 41: 'CP850', // SQL_Latin1_General_CP850_CS_AS
120
+ 42: 'CP850', // SQL_Latin1_General_CP850_CI_AS
121
+ 43: 'CP850', // SQL_Latin1_General_Pref_CP850_CI_AS
122
+ 44: 'CP850', // SQL_Latin1_General_CP850_CI_AI
123
+ 49: 'CP850', // SQL_1xCompat_CP850_CI_AS
124
+ 51: 'CP1252', // SQL_Latin1_General_Cp1_CS_AS_KI_WI
125
+ 52: 'CP1252', // SQL_Latin1_General_Cp1_CI_AS_KI_WI
126
+ 53: 'CP1252', // SQL_Latin1_General_Pref_Cp1_CI_AS_KI_WI
127
+ 54: 'CP1252', // SQL_Latin1_General_Cp1_CI_AI_KI_WI
128
+ 55: 'CP850', // SQL_AltDiction_CP850_CS_AS
129
+ 56: 'CP850', // SQL_AltDiction_Pref_CP850_CI_AS
130
+ 57: 'CP850', // SQL_AltDiction_CP850_CI_AI
131
+ 58: 'CP850', // SQL_Scandinavian_Pref_CP850_CI_AS
132
+ 59: 'CP850', // SQL_Scandinavian_CP850_CS_AS
133
+ 60: 'CP850', // SQL_Scandinavian_CP850_CI_AS
134
+ 61: 'CP850', // SQL_AltDiction_CP850_CI_AS
135
+ 80: 'CP1250', // SQL_Latin1_General_1250_BIN
136
+ 81: 'CP1250', // SQL_Latin1_General_CP1250_CS_AS
137
+ 82: 'CP1250', // SQL_Latin1_General_Cp1250_CI_AS_KI_WI
138
+ 83: 'CP1250', // SQL_Czech_Cp1250_CS_AS_KI_WI
139
+ 84: 'CP1250', // SQL_Czech_Cp1250_CI_AS_KI_WI
140
+ 85: 'CP1250', // SQL_Hungarian_Cp1250_CS_AS_KI_WI
141
+ 86: 'CP1250', // SQL_Hungarian_Cp1250_CI_AS_KI_WI
142
+ 87: 'CP1250', // SQL_Polish_Cp1250_CS_AS_KI_WI
143
+ 88: 'CP1250', // SQL_Polish_Cp1250_CI_AS_KI_WI
144
+ 89: 'CP1250', // SQL_Romanian_Cp1250_CS_AS_KI_WI
145
+ 90: 'CP1250', // SQL_Romanian_Cp1250_CI_AS_KI_WI
146
+ 91: 'CP1250', // SQL_Croatian_Cp1250_CS_AS_KI_WI
147
+ 92: 'CP1250', // SQL_Croatian_Cp1250_CI_AS_KI_WI
148
+ 93: 'CP1250', // SQL_Slovak_Cp1250_CS_AS_KI_WI
149
+ 94: 'CP1250', // SQL_Slovak_Cp1250_CI_AS_KI_WI
150
+ 95: 'CP1250', // SQL_Slovenian_Cp1250_CS_AS_KI_WI
151
+ 96: 'CP1250', // SQL_Slovenian_Cp1250_CI_AS_KI_WI
152
+ 104: 'CP1251', // SQL_Latin1_General_1251_BIN
153
+ 105: 'CP1251', // SQL_Latin1_General_CP1251_CS_AS
154
+ 106: 'CP1251', // SQL_Latin1_General_CP1251_CI_AS
155
+ 107: 'CP1251', // SQL_Ukrainian_Cp1251_CS_AS_KI_WI
156
+ 108: 'CP1251', // SQL_Ukrainian_Cp1251_CI_AS_KI_WI
157
+ 112: 'CP1253', // SQL_Latin1_General_1253_BIN
158
+ 113: 'CP1253', // SQL_Latin1_General_CP1253_CS_AS
159
+ 114: 'CP1253', // SQL_Latin1_General_CP1253_CI_AS
160
+ 120: 'CP1253', // SQL_MixDiction_CP1253_CS_AS
161
+ 121: 'CP1253', // SQL_AltDiction_CP1253_CS_AS
162
+ 122: 'CP1253', // SQL_AltDiction2_CP1253_CS_AS
163
+ 124: 'CP1253', // SQL_Latin1_General_CP1253_CI_AI
164
+ 128: 'CP1254', // SQL_Latin1_General_1254_BIN
165
+ 129: 'CP1254', // SQL_Latin1_General_Cp1254_CS_AS_KI_WI
166
+ 130: 'CP1254', // SQL_Latin1_General_Cp1254_CI_AS_KI_WI
167
+ 136: 'CP1255', // SQL_Latin1_General_1255_BIN
168
+ 137: 'CP1255', // SQL_Latin1_General_CP1255_CS_AS
169
+ 138: 'CP1255', // SQL_Latin1_General_CP1255_CI_AS
170
+ 144: 'CP1256', // SQL_Latin1_General_1256_BIN
171
+ 145: 'CP1256', // SQL_Latin1_General_CP1256_CS_AS
172
+ 146: 'CP1256', // SQL_Latin1_General_CP1256_CI_AS
173
+ 152: 'CP1257', // SQL_Latin1_General_1257_BIN
174
+ 153: 'CP1257', // SQL_Latin1_General_CP1257_CS_AS
175
+ 154: 'CP1257', // SQL_Latin1_General_CP1257_CI_AS
176
+ 155: 'CP1257', // SQL_Estonian_Cp1257_CS_AS_KI_WI
177
+ 156: 'CP1257', // SQL_Estonian_Cp1257_CI_AS_KI_WI
178
+ 157: 'CP1257', // SQL_Latvian_Cp1257_CS_AS_KI_WI
179
+ 158: 'CP1257', // SQL_Latvian_Cp1257_CI_AS_KI_WI
180
+ 159: 'CP1257', // SQL_Lithuanian_Cp1257_CS_AS_KI_WI
181
+ 160: 'CP1257', // SQL_Lithuanian_Cp1257_CI_AS_KI_WI
182
+ 183: 'CP1252', // SQL_Danish_Pref_Cp1_CI_AS_KI_WI
183
+ 184: 'CP1252', // SQL_SwedishPhone_Pref_Cp1_CI_AS_KI_WI
184
+ 185: 'CP1252', // SQL_SwedishStd_Pref_Cp1_CI_AS_KI_WI
185
+ 186: 'CP1252' // SQL_Icelandic_Pref_Cp1_CI_AS_KI_WI
186
+ };