tedious 11.7.0 → 11.8.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.
- package/lib/bulk-load.js +22 -2
- package/lib/data-types/image.js +1 -1
- package/lib/data-types/ntext.js +44 -11
- package/lib/data-types/text.js +1 -1
- package/package.json +1 -1
package/lib/bulk-load.js
CHANGED
|
@@ -54,7 +54,12 @@ const DONE_STATUS = {
|
|
|
54
54
|
* @private
|
|
55
55
|
*/
|
|
56
56
|
|
|
57
|
-
const rowTokenBuffer = Buffer.from([_token.TYPE.ROW]);
|
|
57
|
+
const rowTokenBuffer = Buffer.from([_token.TYPE.ROW]);
|
|
58
|
+
const textPointerAndTimestampBuffer = Buffer.from([// TextPointer length
|
|
59
|
+
0x10, // TextPointer
|
|
60
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
|
61
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
|
62
|
+
const textPointerNullBuffer = Buffer.from([0x00]); // A transform that converts rows to packets.
|
|
58
63
|
|
|
59
64
|
class RowTransform extends _stream.Transform {
|
|
60
65
|
/**
|
|
@@ -120,6 +125,16 @@ class RowTransform extends _stream.Transform {
|
|
|
120
125
|
precision: c.precision,
|
|
121
126
|
value: value
|
|
122
127
|
};
|
|
128
|
+
|
|
129
|
+
if (c.type.name === 'Text' || c.type.name === 'Image' || c.type.name === 'NText') {
|
|
130
|
+
if (value == null) {
|
|
131
|
+
this.push(textPointerNullBuffer);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this.push(textPointerAndTimestampBuffer);
|
|
136
|
+
}
|
|
137
|
+
|
|
123
138
|
this.push(c.type.generateParameterLength(parameter, this.mainOptions));
|
|
124
139
|
|
|
125
140
|
for (const chunk of c.type.generateParameterData(parameter, this.mainOptions)) {
|
|
@@ -554,7 +569,12 @@ class BulkLoad extends _events.EventEmitter {
|
|
|
554
569
|
|
|
555
570
|
tBuf.writeUInt16LE(flags); // TYPE_INFO
|
|
556
571
|
|
|
557
|
-
tBuf.writeBuffer(c.type.generateTypeInfo(c, this.options)); //
|
|
572
|
+
tBuf.writeBuffer(c.type.generateTypeInfo(c, this.options)); // TableName
|
|
573
|
+
|
|
574
|
+
if (c.type.hasTableName) {
|
|
575
|
+
tBuf.writeUsVarchar(this.table, 'ucs2');
|
|
576
|
+
} // ColName
|
|
577
|
+
|
|
558
578
|
|
|
559
579
|
tBuf.writeBVarchar(c.name, 'ucs2');
|
|
560
580
|
}
|
package/lib/data-types/image.js
CHANGED
package/lib/data-types/ntext.js
CHANGED
|
@@ -4,32 +4,65 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
const NULL_LENGTH = Buffer.from([0xFF, 0xFF, 0xFF, 0xFF]);
|
|
7
8
|
const NText = {
|
|
8
9
|
id: 0x63,
|
|
9
10
|
type: 'NTEXT',
|
|
10
11
|
name: 'NText',
|
|
11
12
|
hasTableName: true,
|
|
13
|
+
declaration: function () {
|
|
14
|
+
return 'ntext';
|
|
15
|
+
},
|
|
16
|
+
resolveLength: function (parameter) {
|
|
17
|
+
const value = parameter.value; // Temporary solution. Remove 'any' later.
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
if (value != null) {
|
|
20
|
+
return value.length;
|
|
21
|
+
} else {
|
|
22
|
+
return -1;
|
|
23
|
+
}
|
|
15
24
|
},
|
|
16
25
|
|
|
17
|
-
generateTypeInfo() {
|
|
18
|
-
|
|
26
|
+
generateTypeInfo(parameter, _options) {
|
|
27
|
+
const buffer = Buffer.alloc(10);
|
|
28
|
+
buffer.writeUInt8(this.id, 0);
|
|
29
|
+
buffer.writeInt32LE(parameter.length, 1); // TODO: Collation handling
|
|
30
|
+
|
|
31
|
+
return buffer;
|
|
19
32
|
},
|
|
20
33
|
|
|
21
|
-
generateParameterLength() {
|
|
22
|
-
|
|
34
|
+
generateParameterLength(parameter, options) {
|
|
35
|
+
if (parameter.value == null) {
|
|
36
|
+
return NULL_LENGTH;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const buffer = Buffer.alloc(4);
|
|
40
|
+
buffer.writeInt32LE(Buffer.byteLength(parameter.value, 'ucs2'), 0);
|
|
41
|
+
return buffer;
|
|
23
42
|
},
|
|
24
43
|
|
|
25
|
-
generateParameterData() {
|
|
26
|
-
|
|
44
|
+
generateParameterData: function* (parameter, options) {
|
|
45
|
+
if (parameter.value == null) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
yield Buffer.from(parameter.value.toString(), 'ucs2');
|
|
27
50
|
},
|
|
51
|
+
validate: function (value) {
|
|
52
|
+
if (value == null) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
28
55
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
56
|
+
if (typeof value !== 'string') {
|
|
57
|
+
if (typeof value.toString !== 'function') {
|
|
58
|
+
throw new TypeError('Invalid string.');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
value = value.toString();
|
|
62
|
+
}
|
|
32
63
|
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
33
66
|
};
|
|
34
67
|
var _default = NText;
|
|
35
68
|
exports.default = _default;
|
package/lib/data-types/text.js
CHANGED
package/package.json
CHANGED