Comparing version 11.7.0 to 11.8.0
@@ -57,3 +57,8 @@ "use strict"; | ||
const rowTokenBuffer = Buffer.from([_token.TYPE.ROW]); // A transform that converts rows to packets. | ||
const rowTokenBuffer = Buffer.from([_token.TYPE.ROW]); | ||
const textPointerAndTimestampBuffer = Buffer.from([// TextPointer length | ||
0x10, // TextPointer | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Timestamp | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); | ||
const textPointerNullBuffer = Buffer.from([0x00]); // A transform that converts rows to packets. | ||
@@ -124,2 +129,12 @@ class RowTransform extends _stream.Transform { | ||
}; | ||
if (c.type.name === 'Text' || c.type.name === 'Image' || c.type.name === 'NText') { | ||
if (value == null) { | ||
this.push(textPointerNullBuffer); | ||
continue; | ||
} | ||
this.push(textPointerAndTimestampBuffer); | ||
} | ||
this.push(c.type.generateParameterLength(parameter, this.mainOptions)); | ||
@@ -559,4 +574,9 @@ | ||
tBuf.writeBuffer(c.type.generateTypeInfo(c, this.options)); // ColName | ||
tBuf.writeBuffer(c.type.generateTypeInfo(c, this.options)); // TableName | ||
if (c.type.hasTableName) { | ||
tBuf.writeUsVarchar(this.table, 'ucs2'); | ||
} // ColName | ||
tBuf.writeBVarchar(c.name, 'ucs2'); | ||
@@ -563,0 +583,0 @@ } |
@@ -39,3 +39,3 @@ "use strict"; | ||
const buffer = Buffer.alloc(4); | ||
buffer.writeInt32LE(parameter.length, 0); | ||
buffer.writeInt32LE(parameter.value.length, 0); | ||
return buffer; | ||
@@ -42,0 +42,0 @@ }, |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.default = void 0; | ||
const NULL_LENGTH = Buffer.from([0xFF, 0xFF, 0xFF, 0xFF]); | ||
const NText = { | ||
@@ -13,23 +14,55 @@ id: 0x63, | ||
hasTableName: true, | ||
declaration: function () { | ||
return 'ntext'; | ||
}, | ||
resolveLength: function (parameter) { | ||
const value = parameter.value; // Temporary solution. Remove 'any' later. | ||
declaration() { | ||
throw new Error('not implemented'); | ||
if (value != null) { | ||
return value.length; | ||
} else { | ||
return -1; | ||
} | ||
}, | ||
generateTypeInfo() { | ||
throw new Error('not implemented'); | ||
generateTypeInfo(parameter, _options) { | ||
const buffer = Buffer.alloc(10); | ||
buffer.writeUInt8(this.id, 0); | ||
buffer.writeInt32LE(parameter.length, 1); // TODO: Collation handling | ||
return buffer; | ||
}, | ||
generateParameterLength() { | ||
throw new Error('not implemented'); | ||
generateParameterLength(parameter, options) { | ||
if (parameter.value == null) { | ||
return NULL_LENGTH; | ||
} | ||
const buffer = Buffer.alloc(4); | ||
buffer.writeInt32LE(Buffer.byteLength(parameter.value, 'ucs2'), 0); | ||
return buffer; | ||
}, | ||
generateParameterData() { | ||
throw new Error('not implemented'); | ||
generateParameterData: function* (parameter, options) { | ||
if (parameter.value == null) { | ||
return; | ||
} | ||
yield Buffer.from(parameter.value.toString(), 'ucs2'); | ||
}, | ||
validate: function (value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
validate() { | ||
throw new Error('not implemented'); | ||
if (typeof value !== 'string') { | ||
if (typeof value.toString !== 'function') { | ||
throw new TypeError('Invalid string.'); | ||
} | ||
value = value.toString(); | ||
} | ||
return value; | ||
} | ||
}; | ||
@@ -36,0 +69,0 @@ var _default = NText; |
@@ -40,3 +40,3 @@ "use strict"; | ||
const buffer = Buffer.alloc(4); | ||
buffer.writeInt32LE(parameter.length, 0); | ||
buffer.writeInt32LE(parameter.value.length, 0); | ||
return buffer; | ||
@@ -43,0 +43,0 @@ }, |
@@ -30,3 +30,3 @@ { | ||
"license": "MIT", | ||
"version": "11.7.0", | ||
"version": "11.8.0", | ||
"main": "./lib/tedious.js", | ||
@@ -33,0 +33,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
484813
13384