未验证 提交 06721937 编写于 作者: L Linhe Huo 提交者: GitHub

[TD-4641]<fix>: fix nodejs query result error (#6448)

Update Node.js connector version to v2.0.8
上级 af88f576
...@@ -126,30 +126,20 @@ function convertDouble(data, num_of_rows, nbytes = 0, offset = 0, micro = false) ...@@ -126,30 +126,20 @@ function convertDouble(data, num_of_rows, nbytes = 0, offset = 0, micro = false)
} }
return res; return res;
} }
function convertBinary(data, num_of_rows, nbytes = 0, offset = 0, micro = false) {
function convertNchar(data, num_of_rows, nbytes = 0, offset = 0, micro = false) {
data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset);
let res = []; let res = [];
let currOffset = 0; let currOffset = 0;
while (currOffset < data.length) { while (currOffset < data.length) {
let dataEntry = data.slice(currOffset, currOffset + nbytes); let len = data.readIntLE(currOffset, 2);
if (dataEntry[0] == FieldTypes.C_BINARY_NULL) { let dataEntry = data.slice(currOffset + 2, currOffset + len + 2); //one entry in a row under a column;
res.push(null); res.push(dataEntry.toString("utf-8"));
}
else {
res.push(ref.readCString(dataEntry));
}
currOffset += nbytes; currOffset += nbytes;
} }
return res; return res;
} }
function convertNchar(data, num_of_rows, nbytes = 0, offset = 0, micro = false) {
data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset);
let res = [];
let dataEntry = data.slice(0, nbytes); //one entry in a row under a column;
//TODO: should use the correct character encoding
res.push(dataEntry.toString("utf-8"));
return res;
}
// Object with all the relevant converters from pblock data to javascript readable data // Object with all the relevant converters from pblock data to javascript readable data
let convertFunctions = { let convertFunctions = {
...@@ -160,7 +150,7 @@ let convertFunctions = { ...@@ -160,7 +150,7 @@ let convertFunctions = {
[FieldTypes.C_BIGINT]: convertBigint, [FieldTypes.C_BIGINT]: convertBigint,
[FieldTypes.C_FLOAT]: convertFloat, [FieldTypes.C_FLOAT]: convertFloat,
[FieldTypes.C_DOUBLE]: convertDouble, [FieldTypes.C_DOUBLE]: convertDouble,
[FieldTypes.C_BINARY]: convertBinary, [FieldTypes.C_BINARY]: convertNchar,
[FieldTypes.C_TIMESTAMP]: convertTimestamp, [FieldTypes.C_TIMESTAMP]: convertTimestamp,
[FieldTypes.C_NCHAR]: convertNchar [FieldTypes.C_NCHAR]: convertNchar
} }
......
{ {
"name": "td2.0-connector", "name": "td2.0-connector",
"version": "2.0.7", "version": "2.0.8",
"description": "A Node.js connector for TDengine.", "description": "A Node.js connector for TDengine.",
"main": "tdengine.js", "main": "tdengine.js",
"directories": { "directories": {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册